我试图通过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(),而不是从转换器只是价值观似乎解决这个问题,但我不知道这是在做...

最好的东西
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top