I have the following code that works:
public DataTemplate ItemTemplate { get { return _list.ItemTemplate; } set { _list.ItemTemplate = value; } }
And I have the code that I want to have, but it does not work. Even a setter is never called:
public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(MyUserControl)); public DataTemplate ItemTemplate { get { return (DataTemplate)GetValue(ItemTemplateProperty); } set { _list.ItemTemplate = value; SetValue(ItemTemplateProperty, value); } }
Using this in XAML:
<Window.Resources> <DataTemplate x:Key="ItemTemplate"> <TextBlock Text="{Binding Path=Name}"/> </DataTemplate> </Window.Resources> <local:MyUserControl ItemTemplate="{StaticResource ItemTemplate}"/>
Why are there no standard property and dependency property?
c # wpf xaml
Ryzzard dΕΌegan
source share