4

我想做与这篇文章类似的事情,但使用 MultipleBindings。

所以是这样的:

    <Button.CommandParameter>
        <MultiBinding Converter="{StaticResource commandParametersConverter}">
            <MultiBinding.Bindings>
                <Binding Path="DataContext" />
                <Binding Path="{x:Static vm:Direction.Down}" Mode="OneWay"/>
            </MultiBinding.Bindings>
        </MultiBinding>
    </Button.CommandParameter>

该行:

    <Binding Path="{x:Static vm:Direction.Down}" Mode="OneWay"/>

引发错误:对象引用未设置为对象的实例。我假设在这种情况下不允许使用静态,那么下一个最佳选择是什么?

4

1 回答 1

5

更改Path为:Source_<Binding Path="{x:Static vm:Direction.Down}" Mode="OneWay"/>

<Button.CommandParameter>
    <MultiBinding Converter="{StaticResource commandParametersConverter}">
        <MultiBinding.Bindings>
            <Binding Path="DataContext" />
            <Binding Source="{x:Static vm:Direction.Down}" Mode="OneWay"/>
        </MultiBinding.Bindings>
    </MultiBinding>
</Button.CommandParameter>
于 2012-08-07T16:04:13.487 回答