silverlight中的TextBlock背景色后台动态变化
1个回答
2014-12-30
展开全部
如果只改变字体颜色:
<TextBlock Name="txt">改变颜色</TextBlock>
txt.MouseLeftButtonDown+=txt_MouseLeftButtonDown;
private void txt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
txt.Foreground = new SolidColorBrush(Colors.Orange);
}
要改变背景颜色:
<StackPanel x:Name="spl">
<TextBlock Name="txt">改变颜色</TextBlock>
</StackPanel>
spl.MouseLeftButtonDown+=spl_MouseLeftButtonDown;
private void spl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
spl.Background = new SolidColorBrush(Colors.Orange);
}
但是我不知道动态变化时点击事件吗?
<TextBlock Name="txt">改变颜色</TextBlock>
txt.MouseLeftButtonDown+=txt_MouseLeftButtonDown;
private void txt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
txt.Foreground = new SolidColorBrush(Colors.Orange);
}
要改变背景颜色:
<StackPanel x:Name="spl">
<TextBlock Name="txt">改变颜色</TextBlock>
</StackPanel>
spl.MouseLeftButtonDown+=spl_MouseLeftButtonDown;
private void spl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
spl.Background = new SolidColorBrush(Colors.Orange);
}
但是我不知道动态变化时点击事件吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询