0
我有一個自定義組合框,如果你願意,MultiBinding轉換器在CheckBox.IsChecked不叫
的事情是選擇取決於另一集合multiselectioncombobox。我試圖將ComboBox.IsChecked屬性綁定到MultiBinding Converter,但轉換器未被調用。
<DataTemplate>
<StackPanel Orientation="Horizontal" x:Name="ItemStack" VirtualizingStackPanel.IsVirtualizing="False">
<CheckBox x:Name="CheckBoxItem"
Command="{Binding SelectItem, RelativeSource={RelativeSource AncestorType={x:Type MultiSelectionComboBox}}}"
CommandParameter="{Binding Key}"
>
<CheckBox.IsChecked>
<MultiBinding Converter="{StaticResource MultiSelectionCommandConverter}" Mode="OneWay">
<Binding Path="Key"/>
<Binding Path="SelectedItem"
RelativeSource="{RelativeSource AncestorType={x:Type MultiSelectionComboBox}}" />
</MultiBinding>
</CheckBox.IsChecked>
</CheckBox>
<TextBlock Text="{Binding DisplayText}"></TextBlock>
</StackPanel>
</DataTemplate>
和轉換器,
public class MultiSelectionCommandConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
///stuff to do...
}
public object[] ConvertBack(object values, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}
}
有什麼建議?
可以顯示組合框的完整xaml嗎? – user1064519 2013-04-24 09:56:52
你的輸出中是否有綁定錯誤? – Rachel 2013-04-24 12:58:43