WPF框架中是否有类似BindableObject的东西?
|
我在XAML中定义了DependencyObjectCollecion。我想用其他现有对象(例如按钮,文本框)填充此集合。
我会改用BindableObject的集合。这样做将使我有机会将此类元素绑定到现有对象。
我的问题是:我真的需要自己编写它吗,还是在框架中已经有类似的东西了?
编辑:
像这样:
public class ObjectContainer<T> : DependencyObject
where T : DependencyObject
{
internal const string ObjectPropertyName = \"Object\";
static ObjectContainer()
{
ObjectProperty = DependencyProperty.Register
(
ObjectPropertyName,
typeof(T),
typeof(ObjectContainer<T>),
new PropertyMetadata(null)
);
}
public static DependencyProperty ObjectProperty;
[Bindable(true)]
public T Object
{
get { return (T)this.GetValue(ObjectProperty); }
set { this.SetValue(ObjectProperty, value); }
}
}
没有找到相关结果
已邀请:
0 个回复