关闭

遍历集合下的按钮

288人阅读 评论(0) 收藏 举报

 private void btn_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement feSource = e.Source as FrameworkElement;
            switch (feSource.Name)
            {
                case "btn_Blue":
                    btn_Yellow.Content = "Yellow";
                    btn_Red.Content = "Red";
                    btn_Blue.Content = "Hello Blue!";
                    break;
                case "btn_Yellow":
                    btn_Red.Content = "Red";
                    btn_Blue.Content = "Blue";
                    btn_Yellow.Content = "Hello Yellow!";
                    break;
                case "btn_Red":
                    btn_Blue.Content = "Blue";
                    btn_Yellow.Content = "Yellow";
                    btn_Red.Content = "Hello Red!";
                    break;
            }
      

  <Border Height="80" Width="350" BorderBrush="Red" BorderThickness="4" >
            <StackPanel Background="LightBlue" Orientation="Horizontal" Button.Click="btn_Click" Margin="10,10,10,10" >
                <Button Background="Blue" Name="btn_Blue" Width="80" Margin="10,10,10,10">Blue</Button>
                <Button Background="Red" Name="btn_Red" Width="80" Margin="10,10,10,10">Red</Button>
                <Button Background="Yellow" Name="btn_Yellow" Width="80" Margin="10,10,10,10">Yellow</Button>
            </StackPanel>
        </Border>
  

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:492444次
    • 积分:5855
    • 等级:
    • 排名:第4345名
    • 原创:159篇
    • 转载:115篇
    • 译文:1篇
    • 评论:24条
    博客专栏
    最新评论