如何使用行为更改按钮背景?

问题描述

<Button Height="50" BorderBrush="IndianRed" Margin="5,0"
    x:Name="aBtn">
    <Button.Resources>
       <SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="IndianRed"/>
    </Button.Resources>
    <StackPanel Orientation="Vertical">
       <TextBlock Text="Heating" />
    </StackPanel>
    <iActivity:Interaction.Behaviors>
       <iAction:ChangePropertyAction PropertyName="Background" Value="IndianRed" Targetobject="aBtn" />
    </iActivity:Interaction.Behaviors>

这不起作用。 (我使用的是 WinUI3 预览版 4)

解决方法

TargetObject="{Binding ElementName=aBtn}" 是必需的。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...