日期:2014-05-20  浏览次数:20833 次

菜鸟求助!!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