0

I want to create simple custom control (derived from control and with look defined in generics.xaml). I need to change size of elements defined in generic.xaml, when control is resized! It would be great to write some of that generic.xaml part in C#. Is that possible? Or is there a way to create MVVM like custom control? What i am willing to create is simple blinking led control (on,blinking, off).

1 Answer 1

1

There's more than one question in your post, but I'll answer the pertinent one: can you supplement your generic.xaml with code.

The answer is yes. Simply add generic.xaml.cs and marry the two up the same way UserControls are. That is:

  1. Specify x:class in your generic.xaml
  2. Declare your code-behind as a partial class
  3. Ensure your partial class inherits from ResourceDictionary
Sign up to request clarification or add additional context in comments.

2 Comments

Hmm.. I was expecting to have more fun there (c#). Can i get similar functionality in general.xaml.cs as in usercontrol class (override onrendersize, add event handlers, access elements by name?!)
Overriding OnRenderSize wouldn't make sense for a ResourceDictionary. You can do stuff like add event handlers, or add your own items to the RD via code rather than XAML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.