【发布时间】:2011-06-07 19:47:00
【问题描述】:
请帮助我了解值“ABC”的存储位置。当我运行内存分析器时,我看不到 MyClass 的任何实例,实际上绑定有效并且 GroupBox.Header 获得值 ABC...
感谢您的帮助。
<GroupBox Header="{Binding Path=(local:MyClass.Tag1), RelativeSource={RelativeSource Self}}"
local:MyClass.Tag1="ABC" />
public class MyClass
{
public static readonly DependencyProperty Tag1Property = DependencyProperty.RegisterAttached("Tag1", typeof(object), typeof(MyClass), new UIPropertyMetadata(null));
public static object GetTag1(DependencyObject obj)
{
return obj.GetValue(Tag1Property);
}
public static void SetTag1(DependencyObject obj, object value)
{
obj.SetValue(Tag1Property, value);
}
}
【问题讨论】:
标签: wpf dependency-properties attached-properties