문제

I have a button with a Background color, and I want to send this Background color as the Command Parameter to the Command Binding! How can I do that?

<Button Background="Red" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding this.Background}" />
도움이 되었습니까?

해결책

I think you have to use RelativeSource in the binding...

<Button Background="Red" Command="{Binding ChangeColorCommand}"
        CommandParameter="{Binding 
            RelativeSource={RelativeSource Self}, 
            Path=Background}"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top