我打算用Border做一个鼠标移入变色的效果,模拟一个按钮。但是按如下写法没有效果,如果是grid就可以。请高手赐教。
<Border Name="btn_chuli" Grid.Column="1" Background="#00A6AA" Width="80" Cursor="Hand" CornerRadius="3" MouseLeftButtonDown="btn_chuli_MouseLeftButtonDown" MouseLeftButtonUp="btn_chuli_MouseLeftButtonUp" HorizontalAlignment="Right" > <Border.Style> <Style TargetType="Border"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#53b6c0"></Setter> </Trigger> </Style.Triggers> </Style> </Border.Style> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Foreground="White">查看详情</TextBlock> </Border>
移除Background="#00A6AA"
谢谢,按照您的方法修改为下面这样问题确实解决了。
<Border Name="btn_chuli" Grid.Column="1" Width="80" Cursor="Hand" CornerRadius="3" MouseLeftButtonDown="btn_chuli_MouseLeftButtonDown" MouseLeftButtonUp="btn_chuli_MouseLeftButtonUp" HorizontalAlignment="Right" > <Border.Style> <Style TargetType="Border"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#53b6c0"></Setter> </Trigger> <Trigger Property="IsMouseOver" Value="False"> <Setter Property="Background" Value="#00A6AA"></Setter> </Trigger> </Style.Triggers> </Style> </Border.Style> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Foreground="White">查看详情</TextBlock> </Border>