我想向该堆栈布局添加一个触发器,以便当用户将鼠标悬停时,背景将改变颜色。我已经尝试过StackLayout.Style和StackLayout.Triggers都遇到运行时错误。
对于iSO和Android,有更好的方法吗?
<StackLayout VerticalOptions="Center"
x:Name="slCancerType"
Grid.Row="0"
BackgroundColor="#8cb8e1"
Orientation="Horizontal">
<StackLayout.Style>
<Style TargetType="StackLayout">
<Setter Property="BackgroundColor" Value="Blue"/>
<Style.Triggers>
<Trigger TargetType="StackLayout" Property="StackLayout.IsMouseOver" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</StackLayout.Style>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="ButtonCancerType_Clicked" />
</StackLayout.GestureRecognizers>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Image Source="icons8-search-filled-50_1.png"
Grid.Column="1"
VerticalOptions="Center" />
<Label Text="Enter Form"
TextColor="White"
LineBreakMode="WordWrap"
Grid.Column="2"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"/>
</Grid>
</StackLayout>