I created a user control (FilterPicker
), that has a certain list as a property. This is a dependency property so that it can be set when I use the user control.
public static readonly DependencyProperty StrategiesProperty = DependencyProperty.Register(
"Strategies",
typeof(List<FilterType>),
typeof(FilterPicker),
new FrameworkPropertyMetadata
{
DefaultValue = new List<FilterType> { FilterType.Despike },
PropertyChangedCallback = StrategiesChangedCallback,
BindsTwoWayByDefault = false,
});
I am then trying to define this list in the .xaml file where I use this control.
<Filtering:FilterPicker Grid.Row="1" Strategy="{Binding Strategy}">
<Filtering:FilterPicker.Strategies>
<Filtering1:FilterType>PassThrough</Filtering1:FilterType>
<Filtering1:FilterType>MovingAverage</Filtering1:FilterType>
<Filtering1:FilterType>Despike</Filtering1:FilterType>
</Filtering:FilterPicker.Strategies>
</Filtering:FilterPicker>
However, it doesn't work. StrategiesChangedCallBack
never gets called.
If I set it through a binding, it works fine - just not when I try to define it in the xaml. So this works:
<Filtering:FilterPicker Grid.Row="1" Strategy="{Binding Strategy}" Strategies="{Binding AllStrategies}">
But not the previous snippet. Any ideas on what I'm doing wrong?