IMultiValueConverter值是好的,但CommandParameter为null
-
25-09-2019 - |
题
我试图通过IMultiValueConverter的命令传递几个值(作为命令参数)。该值是正确的,当他们经过转换,但一旦Can_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>
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 ();
}
}
代码工作得很好,当我不使用MultiBinding和转换器,但我需要的MultiBinding所以我可以通过一些额外的信息的命令。
解决方案
返回Values.Clone(),而不是从转换器只是价值观似乎解决这个问题,但我不知道这是在做...
最好的东西不隶属于 StackOverflow