【发布时间】:2016-01-23 17:26:23
【问题描述】:
如何创建一个简单的布尔依赖属性IsInput。该值只能在代码中创建类时设置为true 或false。看起来很简单,但我在网上搜索并没有找到一个明确的例子。
我在网上看到过这样的例子,但我不太清楚我会复制什么来正确创建我自己的 bool 依赖属性。
public static readonly DependencyProperty AncestorProperty =
DependencyProperty.Register("Ancestor", typeof(FrameworkElement), typeof(MyItem),
new FrameworkPropertyMetadata(Ancestor_PropertyChanged));
/// <summary>
/// Event raised when 'Ancestor' property has changed.
/// </summary>
private static void Ancestor_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
MyItem c = (MyItem)d;
c.UpdateHotspot();
}
【问题讨论】: