我有一个按钮与背景颜色,我想送这个背景色为命令参数的命令绑定!我该怎么办呢?

<Button Background="Red" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding this.Background}" />
有帮助吗?

解决方案

我认为你必须在绑定...

要使用的RelativeSource
<Button Background="Red" Command="{Binding ChangeColorCommand}"
        CommandParameter="{Binding 
            RelativeSource={RelativeSource Self}, 
            Path=Background}"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top