[Unity] UserControls, CustomControls and Behaviors
Posted: 11 May 2014, 19:20
I created a few UserControls following your tutorial for Unity. I've got them working within Unity but unfortunately Visual Studio gives me build errors now.
The problem is that the class-name in the 'code-behind'-file is of course the same as the one in the xaml. Now VS tells me that I should use the partial modifier. If I do this VS complains that they must not use different base-classes, as the one in the source file inherits from Noesis.UserControl and the one in Xaml inherits from System.Windows.Controls.UserControl.
Is there any way around this problem as I find it very unfortunate not to be able to build it with VS (or Blend)?
I also saw that there is a tutorial for custom controls. So is it somehow possible to create custom controls using NoesisGUI for Unity?
I also tried to create a WPF-behavior but had trouble accessing it within xaml. Afair it was telling me that I couldn't find the behavior.
One more question for now. I was working on a draggable window. I started off creating a draggable panel and added an extension method BringToForeground() to the FrameworkElement. The next step would be to create the draggable window but I'm not sure which way to go as I don't really know what possibilities there are.
Can I inherit from a HeaderedContentControl and just overwrite its templates?
Or do I have to create another UserControl with an additional Header property? Well, I tried to go that route but I'm not allowed to register "object" as a dependency property. The problem with that is that if I'm going to support FrameworkElements (or maybe BaseComponent) only then I can't support strings any more.
I could also go the way with less flexibility and just add a title, titlebar buttons, content, etc.
So what's the best way to go? Maybe there is a completely different solution that I missed so far.
The problem is that the class-name in the 'code-behind'-file is of course the same as the one in the xaml. Now VS tells me that I should use the partial modifier. If I do this VS complains that they must not use different base-classes, as the one in the source file inherits from Noesis.UserControl and the one in Xaml inherits from System.Windows.Controls.UserControl.
Is there any way around this problem as I find it very unfortunate not to be able to build it with VS (or Blend)?
I also saw that there is a tutorial for custom controls. So is it somehow possible to create custom controls using NoesisGUI for Unity?
I also tried to create a WPF-behavior but had trouble accessing it within xaml. Afair it was telling me that I couldn't find the behavior.
One more question for now. I was working on a draggable window. I started off creating a draggable panel and added an extension method BringToForeground() to the FrameworkElement. The next step would be to create the draggable window but I'm not sure which way to go as I don't really know what possibilities there are.
Can I inherit from a HeaderedContentControl and just overwrite its templates?
Or do I have to create another UserControl with an additional Header property? Well, I tried to go that route but I'm not allowed to register "object" as a dependency property. The problem with that is that if I'm going to support FrameworkElements (or maybe BaseComponent) only then I can't support strings any more.
I could also go the way with less flexibility and just add a title, titlebar buttons, content, etc.
So what's the best way to go? Maybe there is a completely different solution that I missed so far.