3

我有一个带有背景颜色的按钮,我想将此背景颜色作为命令参数发送到命令绑定!我怎样才能做到这一点?

<Button Background="Red" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding this.Background}" />
4

1 回答 1

13

我认为您必须在绑定中使用RelativeSource ...

<Button Background="Red" Command="{Binding ChangeColorCommand}"
        CommandParameter="{Binding 
            RelativeSource={RelativeSource Self}, 
            Path=Background}"/>
于 2010-03-05T12:32:01.920 回答