11
我有一個textblock,當前有一個觸發器,當鼠標進入時設置前景色,當它離開時返回默認值。我的問題是,我也想將鼠標指針改變我目前有以下如何編寫WPF觸發器來改變文本塊懸停上的光標
<Style TargetType="TextBlock" x:Key="FlatStyleButton">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#FF333333" />
<Style.Triggers>
<EventTrigger RoutedEvent="UIElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="Foreground.Color" To="CornflowerBlue" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="Foreground.Color" To="White" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
我曾嘗試加入<Setter Property="Cursor" Value="Hand"></Setter>
到各個地方,但它似乎從來沒有工作
有一個觸發器來做到這一點,在http://stackoverflow.com/questions/1132971/wpf-trigger-to-change-cursor – 2013-05-16 10:33:07
這也可以幫助你http://www.infragistics.com/community/forums/t/62255.aspx – 2013-05-16 10:34:21
我已經嘗試過這樣的東西,它沒有工作 – John