2012-08-23 106 views
0

我有一組數值的組合框。所選值由具有多個雙向綁定的Converter確定。當用戶更改ComboBox中的值時,我期望ConvertBack方法被調用並更改多重綁定中使用的兩個屬性的值,但即使ComboBox失去焦點,這種情況也不會發生。我試圖將UpdateSourceTrigger屬性更改爲「LosesFocus」,但這顯然對於MultipleBinding無效。我該如何獲取ConvertBack方法來觸發,無論是當數值發生變化或控件失去焦點時?要麼爲我的目的工作。對於WPF轉換器MultipleBinding ...什麼時候ConvertBack被調用?

XAML:

<ComboBox ItemsSource="{Binding DescriptionList}" DisplayMemberPath="Description" SelectedValuePath="Description" IsEnabled="{Binding EditMode}"> 
    <ComboBox.SelectedValue> 
     <MultiBinding Converter="{StaticResource DescriptionConverter}"> 
      <Binding Path="PersonRow.DescriptionType" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" /> 
      <Binding Path="PersonRow.DescriptionSuccessful" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" /> 
     </MultiBinding> 
    </ComboBox.SelectedValue> 
</ComboBox> 

回答

1

你可能需要添加Mode="TwoWay"<MultiBinding>

+0

我嘗試添加Mode =「TwoWay」到MutiBinding標記,但ConvertBack方法仍然不會觸發。 – jpaull

+0

@jpaull我也從子綁定中刪除'Mode'和'UpdateSourceTrigger'屬性。你也可以在'MultiBinding'上添加'UpdateSourceTrigger'。 – Jay

0

周杰倫的建議暗示我在正確的方向。我還爲MultiBinding標籤添加了一個UpdateSourceTrigger =「LostFocus」,並能夠觸發該事件。

相關問題