Pergunta

Estou tentando passar vários valores através de um imultivalueConverter para um comando (como o parâmetro de comando). Os valores estão corretos quando passam pelo conversor, mas uma vez que os comands can_execute () e execute () são chamados, recebo uma matriz de objetos nulos. Alguma ideia?

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 CLASSE:

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 ();
        }
    }

O código funcionou bem quando eu não estava usando um multibinding e um conversor, mas preciso da multibinding para poder passar algumas informações extras para o comando.

Foi útil?

Solução

Retornar valores.clone () em vez de apenas valores do conversor parece corrigir o problema, mas não tenho certeza se essa é a melhor coisa a fazer ...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top