我有以下在 .NET 3.5 中完美运行的依赖属性定义:
public static readonly DependencyProperty SelectedIdsProperty =
DependencyProperty.Register(
"SelectedIds",
typeof(IEnumerable),
typeof(AddressBookSelector),
new UIPropertyMetadata(null, UpdateUIText));
public IEnumerable SelectedIds
{
get { return (IEnumerable)GetValue(SelectedIdsProperty); }
set
{
SetValue(SelectedIdsProperty, value);
}
}
static void UpdateUIText(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
{
(depObj as AddressBookSelector).UpdateRichTextBox();
}
当我编译代码以在 .NET 4.0 上运行时,当 SelectedIds 的值发生更改时,不再调用 UpdateUIText。我该如何纠正?