2011-03-31 113 views
0

我有一个自定义控件,该属性是另一个自定义控件的ObservableCollection。我似乎无法让设计时间触发DependencyProperty更改事件。我试图使用CoerceValueCallback,这也不会触发。任何人都可以给我一些方向。其他任何东西都在运行时工作得很好,我只是无法让它触发,所以我可以在设计时更新控件。提前谢谢了。依赖属性已更改在设计中的集合属性上未触发的事件时间

Public Shared ReadOnly ArcsProperty As DependencyProperty = DependencyProperty.Register("Arcs", GetType(ObservableCollection(Of OPCWPF.OPCWPFArcControl)), GetType(OPCWPFPie), New PropertyMetadata(New ObservableCollection(Of OPCWPF.OPCWPFArcControl), New PropertyChangedCallback(AddressOf ArcsPropertyChanged), New CoerceValueCallback(AddressOf CoerceArcs))) 

' Arc Quantity 
<Description("Collection of Arcs"), _ 
Category("Common Properties")> _ 
Public Property Arcs() As ObservableCollection(Of OPCWPF.OPCWPFArcControl) 
    Get 
     Return DirectCast(Me.GetValue(ArcsProperty), ObservableCollection(Of OPCWPF.OPCWPFArcControl)) 
    End Get 

    Set(ByVal value As ObservableCollection(Of OPCWPF.OPCWPFArcControl)) 
     Me.SetValue(ArcsProperty, value) 
    End Set 
End Property 

回答

0

简单的解决方案(也许不是最好的),但它让我找到了我想要的东西。

Public Overrides Sub OnApplyTemplate() 
    MyBase.OnApplyTemplate() 
    AddHandler Arcs.CollectionChanged, AddressOf UpdateControl 
End Sub 
0

通过你与你是刚刚订阅的财产本身变化的依赖项属性的元数据注册事件,不更改集合(添加/删除项目)需要通过事件登记认购CollectionChangedObservableCollection<T>曝光

+0

谢谢你的回应。我明白你在说什么。但我不知道如何更改DP以包含CollectionChanged。你可以授予代码片段吗? – Paul 2011-03-31 21:17:46

相关问题