我写了个例子给你,不肯定是不是你要实现的效果哈。(基于c#)
前端代码:
Grid
StackPanel
Button Background=Blue Name=btn Width=100 Height=100 Click=btn_Click/Button
TextBlock Name=txt Text=null HorizontalAlignment=Center/
/StackPanel
/Grid
后台代码
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
string tag=string.Empty;
private void btn_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
if (tag == string.Empty)
{
btn.Background = new SolidColorBrush(Colors.Red);
txt.Text = 0;
tag = 0;
}
else
{
btn.Background = new SolidColorBrush(Colors.Blue);
txt.Text = null;
tag = string.Empty;
}
}
}
取消
评论