<DataTemplate x:Key="MyTemplate" DataType="{x:Type l:MyViewModel}">
<l:MyView />
</DataTemplate>
Is there any way I can replace the "MyTemplate" with a value from a class of mine?
public sealed class MyTemplateSelector : DataTemplateSelector
{
public const string TemplateName = "MyTemplate";
//I use the TemplateName const to retrieve the correct DataTemplate
}
<DataTemplate x:Key="{x:Static l:MyTemplateSelector.TemplateName}"
DataType="{x:Type l:MyViewModel}">
<l:MyView />
</DataTemplate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With