列表/组合框/文本框控件要基于其他控件启用/禁用 [英] List/Combobox/TextBox Controls to be enabled/disabled based on other controls

查看:61
本文介绍了列表/组合框/文本框控件要基于其他控件启用/禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

在我的WPF应用程序中,我没有几个控件,即列表框(A)和组合框(B)和文本框(C),我需要禁用实体,即,如果用户从列表框选择(A)任何值, ComboBox和TextBox中的两项均应被禁用,反之亦然.
即,

< listbox name ="MyListBox" verticalalignment ="Top" .isenabled ="...>值1/Value2/Value3</ListBox>< br模式=" hold ="/><< br模式="top =" SelectedIndex ="combo1 ="><< br mode ="mytextbox =""height =" 20>万一我们不得不使用Checkbox定位问题(相对于上述控件),我们将使用以下语法"{Binding ElementName ="Checkbox",IsPath ="IsChecked}",...等目标,

但是,如果控件不是Checkbox,则如何实现xaml语法?并在上述三个实体互斥的情况下??

解决上述问题的任何帮助都将是可观的.


问候,
Samanth_90

Dear All,

In my WPF Application, I have few controls viz., List Box(A) and ComboBox(B) and TextBox(C), I need to disable the entities, ie., If User selects (A) any value from List Box, Both items in ComboBox and TextBox should be disabled and vice versa.
viz.,

<listbox name="MyListBox" verticalalignment="Top" .isenabled="...>Value 1/Value2/Value3</ListBox><br mode=" hold=" /><<br mode=" top=" SelectedIndex=" combo1="><<br mode=" mytextbox="" height="20">In Case we had to target the problem using Checkbox(relative to above controls) We would target using below syntax "{Binding ElementName="Checkbox", IsPath="IsChecked}",... etc.,

But, how to effect xaml Syntax if the controls are other than Checkbox.? and in context of mutually exclusive for above three entities.?

Any Help in resolving the above would be appreciable.


With Regards,
Samanth_90

推荐答案

,首先,您需要为列表框进行一次selectionChanged事件,然后在此处使组合框和文本框启用为false.
in easy way fist you need to make one selectionChanged event for you list box and here make your combobox and textbox isenabled proeprty as false
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //......
            textbox1.IsEnabled = false;
            combobox1.IsEnabled = false;
        }


在这里
是列表框的用户Chang值,这意味着一次选择组合框和文本框中的列表框中的任何项目


here
is user Chang value for list box that means that select any of item in list box at a time combobox and textbox will be disabled


这篇关于列表/组合框/文本框控件要基于其他控件启用/禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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