Page 1 of 1

[Unity] Inheriting from classes other than UserControl

Posted: 15 Feb 2015, 15:52
by Scherub
I need to implement a special tab-like control that works similar to the WinPhone tab-like control. For that I need two new controls, my own custom TabControl inherited from Selector and another one inherited from HeaderedContentControl.

Before I start trying to implement it in Noesis I just wanted to be sure that's possible to achieve with the current v1.2. I'm asking because it was always said that you can only inherit from UserControl, other FrameworkElements don't provide everything you would need.

Re: [Unity] Inheriting from classes other than UserControl

Posted: 15 Feb 2015, 21:30
by Scherub
*sigh*

I started off writing this in WPF first. Due to the previously mentioned uncertainties I decided after a while to just use UserControls. That required a few more implementation details but in the end it works.
<local:SwipeTabControlView Background="SlateGray" Margin="20">
	<local:SwipeTabControlView.Tabs>
		<local:SwipeTabItemView Header="Header 1">
			<TextBlock Text="Content 1" />
		</local:SwipeTabItemView>

		<local:SwipeTabItemView Header="Header 2">
			<TextBlock Text="Content 2" />
		</local:SwipeTabItemView>

		<local:SwipeTabItemView Header="Header 3">
			<TextBlock Text="Content 3" />
		</local:SwipeTabItemView>	
</local:SwipeTabControlView>

After that I tried to convert it to NoesisGUI but failed miserably as apparently it is not possible to register any kind of collection as a dependency property. First I thought it affects only generic types but I'm not even allowed to use the non-generic IEnumerable. Am I just doing something wrong or is this really not supported? *sigh*

I'll also file a bug report.

Re: [Unity] Inheriting from classes other than UserControl

Posted: 15 Feb 2015, 21:40
by Scherub
Okay, it looks like Noesis.Collection is the only type of collection that works. But I thought this one is going to be deprecated/removed in v1.2?

Edit: Okay, I give up for now. The old collection doesn't have a CollectionChanged event.

Re: [Unity] Inheriting from classes other than UserControl

Posted: 16 Feb 2015, 16:58
by sfernandez
I answered these questions in the ticket you opened about the Collection property problem.

Re: [Unity] Inheriting from classes other than UserControl

Posted: 17 Feb 2015, 15:36
by jsantos
I'm asking because it was always said that you can only inherit from UserControl, other FrameworkElements don't provide everything you would need.
Yes, you can inherit, although the functionality is quite limited right now. Basically you can extend any class adding new dependency properties and events but the expected virtual functions are yet not there (OnMouseMove, OnMouseEnter,...).

If you have a list of virtual functions you are missing, please file a bug and we will try to have them as soon as possible.