【发布时间】:2012-03-17 05:56:24
【问题描述】:
我需要有一个故事板,它可以改变我的 TextBox 中的前景。问题是这个 TextBox 必须在 DataTemplate 中。
如何更改我的 xaml 以使其正常工作?
<DataTemplate x:Key="contentTexBox">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Duration="0" To="Pink" Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="tbContent"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBox Text="Test text" Width="200" Height="35" Foreground="Blue" x:Name="tbContent" BorderBrush="Purple">
</TextBox>
</Grid>
</DataTemplate>
【问题讨论】:
-
对不起,我想我没听懂这个问题,因为您的示例有效。有什么问题?
-
鼠标悬停时前景是否从粉色变为蓝色?
标签: silverlight storyboard datatemplate