【发布时间】:2012-08-20 11:58:09
【问题描述】:
我有一个绑定到属性(数据类型为 int 的 CustomerId)的文本框。这个文本框最初显示一个 0(零),但我想要一个没有输入的清晰文本框。
我还将其默认值设置为 null,如下面的代码:
ValueProperty = DependencyProperty.Register(
"Value",
typeof(int?), typeof(ChooseCustomerControl),
new FrameworkPropertyMetadata(null));
我怎样才能做到这一点?
【问题讨论】:
-
CustomerId与Value有什么关系?我们说的是同一个属性吗? -
Value={绑定路径=CustomerId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}
-
但是您说您有一个“绑定到属性 CustomerId 的文本框”。那我猜你绑定
TextBox.Text。那么Value是干什么用的? -
或者
Value可能是派生文本框的属性?
标签: wpf data-binding binding