TypeArguments for generic UserControl
Good afternoon. WPF supports the x:TypeArguments property, which allows you to create a generalized usercontrol. Noesis does not have this feature. Is there an alternative approach? Is it possible to add it in future versions of Noesis?
Example
Example
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: TypeArguments for generic UserControl
There are no plans to support x:TypeArguments, but I think it won't be necessary.
If you plan to have a different xaml for each implementation of your generic class, then you just specify that concrete class in the xaml:
And if you plan to share the same xaml you can just use UserControl as root without x:Class and point to the same xaml in the InitializeComponent() method:
Could that work for you?
If you plan to have a different xaml for each implementation of your generic class, then you just specify that concrete class in the xaml:
Code: Select all
class GenericControl<T> : UserControl { ... }
class Test1Control : GenericControl<Test1> { ... }
Code: Select all
<UserControl x:Class="Testing.Test1Control" >...</UserControl>
Code: Select all
class Test1Control : GenericControl<Test1>
{
public Test1Control() {
InitializeComponent();
}
private void InitializeComponent() {
Noesis.GUI.LoadComponent(this, "Assets/Xaml/GenericControl.xaml");
}
}
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: TypeArguments for generic UserControl
Your solution of defining a base class with the concrete type looks the best approach to make it work in both Blend and Noesis.
I don't see any other way to workaround the lack of TypeArguments, sorry.
I don't see any other way to workaround the lack of TypeArguments, sorry.
Who is online
Users browsing this forum: Google [Bot] and 73 guests