读书人

初学者!WPF做一个Button和一个Rectan

发布时间: 2012-05-22 18:18:54 作者: rapoo

菜鸟求助!!WPF做一个Button和一个Rectangle,使点击Button的时候Rectangle变色~~
做一个Button和一个Rectangle,使点击Button的时候Rectangle从原来的白色变成绿色



[解决办法]

C# code
private void button1_Click(object sender, RoutedEventArgs e)        {            SolidColorBrush myBrush = new SolidColorBrush(Colors.Green);            this.rectangle1.Fill = myBrush;        }
[解决办法]
private void button1_Click(object sender, RoutedEventArgs e)
{
if (this.isClicked == false)
{
this.button1.IsEnabled = false;
}
else
{
this.isClicked = false;
this.rectangle1.Style = (Style)this.FindResource("rect1Style");
this.button1.IsEnabled = false;
}
}
自己写个rect1Style

读书人网 >.NET Framework

热点推荐