In a previous post I asked how to register a property as DependencyProperty. I got an answer and it works fine.
But now I want to add some Items to this DependencyProperty on a Click. This doesn't work. My code to register the DependencyProperty is:
public static readonly DependencyProperty ChartEntriesProperty = DependencyProperty.Register(
"ChartEntries", typeof(ObservableCollection<ChartEntry>), typeof(ChartView),
new FrameworkPropertyMetadata(OnChartEntriesChanged));
private static void OnChartEntriesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}
The OnChartEntriesChanged-Event is called at the moment I do the Binding from my XAML to my c#-code. But if I add a ChartEntry afterwards (on button-click) the event is not fired.
Does anyone know why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…