星宸楚梦

我本微末凡尘,可也心向天空

遍历集合下的按钮

 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>
  

 

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nanshan_hzq/article/details/7389506
文章标签: button border object
个人分类: wpf
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

遍历集合下的按钮

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭