Ama*_*duh 3 wpf multibinding commandparameter
我试图通过IMultiValueConverter将几个值传递给命令(作为命令参数).这些值在通过转换器时是正确的,但是一旦调用了Can_Execute()和Execute()命令,我就会获得一个空对象数组.有任何想法吗?
XAML:
<Button Content="+" HorizontalAlignment="Right" VerticalAlignment="Top" Width="23" Height="23" Margin="0,0,0,0">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource Converter_MultipleValues}">
<Binding/>
</MultiBinding>
</Button.CommandParameter>
<Button.Command>
<Binding Path="Command_Add_Files" Source="{StaticResource Vm_FileList}"/>
</Button.Command>
</Button>
Run Code Online (Sandbox Code Playgroud)
IMultiValueConverter类:
class cvt_multivalue : IMultiValueConverter {
public object Convert (object[] Values, Type Target_Type, object Parameter, CultureInfo culture) {
if (Target_Type != typeof (object)) throw new NotSupportedException ();
return Values;
}
public object [] ConvertBack (object Value, Type [] Target_Type, object Parameter, CultureInfo culture) {
throw new NotSupportedException ();
}
}
Run Code Online (Sandbox Code Playgroud)
当我没有使用MultiBinding和转换器时,代码工作得很好,但我需要MultiBinding,所以我可以将一些额外的信息传递给命令.