在WPF中选择组合框选定值时如何显示组框控件 [英] how to show groupbox controls when selecting a combobox selected value in WPF

查看:57
本文介绍了在WPF中选择组合框选定值时如何显示组框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示我的Groupboxes及其关于组合框选择值的控件..



当我选择了combobox选择的事件被执行并且我的开关案例是执行

但是群组可见性的最终输出对我来说是错误的..



请帮帮我!!

I want to show my Groupboxes and its controls with respect to the combobox selected value..

when i selected combobox selected event is executed and my switch cases are executing
but final output of group box visibility is wrong for me..

help me please!!

推荐答案

public partial class MainWindow : Window
   {
       public MainWindow()
       {
           InitializeComponent();
       }

       private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
       {
           cmbnum.Items.Add("1");
           cmbnum.Items.Add("2");
       }

       private void cmbnum_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
       {
           if(cmbnum.SelectedItem == "1")
           {
               grp1.Visibility = Visibility.Hidden;
           }
           else
           {
               grp1.Visibility = Visibility.Visible;
           }
       }
   }





在设计级别执行此代码之前请对所有控件进行分组在Groupbox to Grid中。这将解决您的问题。

如果您想在groupbox中专门显示控件,则需要设置每个控件可见性



before executing this code on design level please group all the controls inside Groupbox to Grid. this will solve your problem.
if u want to display controls specifically inside groupbox then every control visibility need to be set


这篇关于在WPF中选择组合框选定值时如何显示组框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆