我有两个文本框,一个用于帐单地址字段,另一个用于发货地址字段。当用户在帐单地址文本框中键入内容时,由于以下绑定方案,发货地址文本框将获得相同的值:
<TextBox Name="txtBillingAddress" Text="{Binding BillingAddress, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<TextBox Name="txtShippingAddress">
<TextBox.Text>
<MultiBinding Converter="{StaticResource AddressConverter}">
<Binding ElementName="txtBillingAddress" Path="Text" Mode="OneWay" />
<Binding Path="ShippingAddress" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" />
</MultiBinding>
</TextBox.Text>
</TextBox>这在一定程度上可以很好地工作。我还希望将发货地址绑定到我的数据库实体,因为帐单地址是。我的问题是,虽然送货地址文本框填充了帐单地址中键入的内容,但在发生这种情况时,ConvertBack方法并未触发。只有在送货地址文本框中直接键入内容时才会触发。
我遗漏了什么?
发布于 2009-07-23 08:56:12
也许这会更容易在你的ViewModel中实现?
public string BillingAddress{
set{
billingAddress = value;
firePropertyChanged("BillingAddress");
if(string.isNullOrEmpty(ShippingAddress)
{
ShippingAddress = value; //use the property to ensure PropertyChanged fires
}
}
get{ return billingAddress; }
}https://stackoverflow.com/questions/1168419
复制相似问题