有没有办法指定自定义依赖属性的默认绑定模式和更新触发器? [英] Is there a way to specify a custom dependency property's default binding mode and update trigger?
本文介绍了有没有办法指定自定义依赖属性的默认绑定模式和更新触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个依赖属性之一的例子:
public static readonly DependencyProperty BindableSelectionLengthProperty =
DependencyProperty.Register(
BindableSelectionLength,
typeof(int),
typeof(ModdedTextBox),
new PropertyMetadata(OnBindableSelectionLengthChanged));
解决方案
注册属性时,使用以下命令初始化元数据: / p>
新的FrameworkPropertyMetadata
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
}
I would like to make it so that, as default, when I bind to one of my dependency properties the binding mode is two-way and update-trigger is property changed. Is there a way to do this?
Here is an example of one of my dependency properties:
public static readonly DependencyProperty BindableSelectionLengthProperty =
DependencyProperty.Register(
"BindableSelectionLength",
typeof(int),
typeof(ModdedTextBox),
new PropertyMetadata(OnBindableSelectionLengthChanged));
解决方案
When registering the property, initialize your metadata with:
new FrameworkPropertyMetadata
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
}
这篇关于有没有办法指定自定义依赖属性的默认绑定模式和更新触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文