7
我從我的複選框命令發送了多個參數。我已經使用了一個轉換器。代碼如下。如果我把一個調試器,看看這裏的值是我的結果:爲什麼這個多重綁定不起作用
當複選框檢查選中或未unchekcked:
在有TEH值(項目目標和布爾數組)的轉換器。但是,當我來我的方法,所述值是一個目的[2]但是兩個值都爲NULL
複選框XAML
<CheckBox x:Name="checkBox"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Data.Label}"
ClickMode="Release"
Command="{Binding Path=DataContext.SelectUnSelect}">
<CheckBox.CommandParameter>
<MultiBinding Converter="{StaticResource SelectedItemConverter}">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Content.Data"/>
<Binding RelativeSource="{RelativeSource Self}" Path="IsChecked"/>
</MultiBinding>
</CheckBox.CommandParameter>
轉換器:
public class CheckConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return values;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
查看模型命令代碼:
public ICommand SelectUnSelect
{
get { return new RelayCommand<object>(parm => this.SelectAndUnSelect(parm));}
}
如果我把一個調試器放在SelectAndUnSelect方法中,它會在parm中顯示對象[2],但它們都是空的。
觀察:如果我將我的命令參數綁定到任何一個綁定,它都可以正常工作。
我在這裏失蹤了什麼?
- 桑卡
這工作。不知道爲什麼它不能提前工作。 – Shankar
也適用於我。我很想知道它爲什麼只能這樣工作,而不是通過返回對象數組。 – csteinmueller