문제
청구서 주소 필드와 하나는 배송 주소 필드를위한 두 개의 텍스트 상자가 있습니다. 사용자가 청구서 주소 텍스트 상자에 무언가를 입력하면 다음 바인딩 시나리오로 인해 배송 주소 텍스트 상자가 동일한 값을 얻습니다.
<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 메소드가 발생하는 동안 발사되지 않는다는 것입니다. 배송 주소 텍스트 상자에 직접 입력 한 경우에만 해고됩니다.
내가 무엇을 놓치고 있습니까?
해결책
어쩌면 이것이 뷰 모델에서 구현하기가 더 쉬울까요?
public string BillingAddress{
set{
billingAddress = value;
firePropertyChanged("BillingAddress");
if(string.isNullOrEmpty(ShippingAddress)
{
ShippingAddress = value; //use the property to ensure PropertyChanged fires
}
}
get{ return billingAddress; }
}
제휴하지 않습니다 StackOverflow