Điều gì xác định thứ tự mà nhiều DepdencyProperties trên cùng một điều khiển được đánh giá?Thứ tự mà các ràng buộc DependencyProperties được đánh giá?
Tôi đang sử dụng Extended WPF Toolkit PropertyGrid và có cả SelectedObject và PropertyDefinitions ràng buộc:
<extToolkit:PropertyGrid AutoGenerateProperties="False" SelectedObject="{Binding ActiveDataPoint}" PropertyDefinitions="{Binding ActiveDataPoint.Properties}">
Vấn đề là các đám cháy OnSelectedObjectChanged từ tài sản phụ thuộc, và trong đó xử lý thay đổi nó được tham khảo PropertyDefinitions, mà nó là thấy là rỗng. Nếu tôi nhận xét xử lý OnSelectedObjectChanged sau đó tôi có thể nhìn thấy khi gỡ lỗi mà OnPropertyDefinitionsChanged được gọi là SAU cuộc gọi đến OnSelectedObjectChanged.
public static readonly DependencyProperty PropertyDefinitionsProperty = DependencyProperty.Register("PropertyDefinitions", typeof(PropertyDefinitionCollection), typeof(PropertyGrid), new UIPropertyMetadata(null, OnPropertyDefinitionsChanged));
public PropertyDefinitionCollection PropertyDefinitions
{
get
{
return (PropertyDefinitionCollection)GetValue(PropertyDefinitionsProperty);
}
set
{
SetValue(PropertyDefinitionsProperty, value);
}
}
private static void OnPropertyDefinitionsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
Console.Write("I changed!");
}
public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty.Register("SelectedObject", typeof(object), typeof(PropertyGrid), new UIPropertyMetadata(null, OnSelectedObjectChanged));
public object SelectedObject
{
get
{
return (object)GetValue(SelectedObjectProperty);
}
set
{
SetValue(SelectedObjectProperty, value);
}
}
private static void OnSelectedObjectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
PropertyGrid propertyInspector = o as PropertyGrid;
if(propertyInspector != null)
propertyInspector.OnSelectedObjectChanged((object)e.OldValue, (object)e.NewValue);
}
Vấn đề tôi đang phải đối mặt sẽ được thảo luận trên this forum thread, nhưng tôi hỏi một WPF câu hỏi tổng quát hơn như thế nào tôi có thể thay đổi thứ tự mà các đặc tính này được cập nhật.
Tôi đã thử thực hiện nhiều lệnh gọi đến NotifyPropertyChanged theo các đơn đặt hàng khác nhau nhưng điều đó dường như không ảnh hưởng đến điều này. Tôi có thể khiến đơn đặt hàng khác hoặc tôi chỉ cần sửa đổi PropertyGrid để nó có thể hoạt động cho một trong hai đơn hàng?