我在我的视图模型中有int
类型的属性,该属性绑定到TextBox
。一切工作正常,TwoWay
绑定工作,细除了一种情况 -WPF绑定与int类型的属性无法正常工作
如果我明确的TextBox
值,属性setter不会被调用,虽然值在TextBox
清除,物业仍占据前值。
有人遇到过类似的问题吗?有没有解决这个问题的方法?
这里是财产 -
public int MaxOccurrences
{
get
{
return this.maxOccurrences;
}
set
{
if (this.maxOccurrences != value)
{
this.maxOccurrences = value;
base.RaisePropertyChanged("MaxOccurrences");
}
}
}
这是我如何结合我在XAML属性 -
<TextBox Text="{Binding Path=MaxOccurrences, Mode=TwoWay,
NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Center" Width="30" Margin="0,0,5,0"/>
我很想知道这种行为在silverlight中是否相同?任何人! – akjoshi 2010-09-03 09:41:59
Silverlight中的行为与Silverlight中不支持的NotifyOnSourceUpdated和UpdateSourceTrigger之类的数据绑定属性除外。 – 2010-09-21 19:45:02