根据复选框状态启用或禁用组框 [英] Enable or Disable Group box based on Check box State

查看:83
本文介绍了根据复选框状态启用或禁用组框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

以下摘录是从ABCProduct.xaml中提取的,用于WPF应用程序.

< GroupBox Header ="NewType" name ="Typ1" Grid.Row ="2" BorderBrush ="Gray" BorderThickness ="1">
< CheckBox名称="ProductCheckBox"> Prod.CheckBox</CheckBox>
</GroupBox>
< GroupBox Header ="SWG_ProductType" name =< b>"{{BindingElementName = Typ1,Path = IsChecked}"></b> Grid.Row ="3" ...>
......
......其他控件<!-<即浏览器,单选按钮等--
......
</GroupBox>

未找到错误为"BindingElementName".要验证缺少的程序集引用",等等,



使用绑定复选框和Path = IsChecked的元素名称来绑定Group Box控件"的工作正在XAML解析器中给出错误,您能否建议我们如何实现相同的功能?



即,我们如何禁用或启用组框<<< SWG_ProductType>>复选框状态为基础的实体.

在此先感谢...

问候,
Samanth

Hi All,

The following snippet is extracted from ABCProduct.xaml, for WPF Application.

<GroupBox Header="NewType" name="Typ1" Grid.Row="2" BorderBrush="Gray" BorderThickness="1">
<CheckBox Name="ProductCheckBox">Prod.CheckBox</CheckBox>
</GroupBox>
<GroupBox Header="SWG_ProductType" name=<b>"{BindingElementName=Typ1,Path =IsChecked}"></b> Grid.Row="3" ...>
......
......other Controls <!-<<viz., Radio Buttons etc., -->
......
</GroupBox>

"The Error is "BindingElementName" was not found. To verify missing assembly reference" etc.,



The work around for Binding the Group Box controls using "Binding Element Name for Check box and Path= IsChecked is giving error in XAML parser, could you suggest how could we implement the same.



ie., How can we disable or enable the Group Box <<SWG_ProductType>> entities based on Check box State.

Thanks in Advance...

With Regards,
Samanth

推荐答案

您有2个错误:

You have 2 mistakes:


  1. 您忘记在BindingElementName之间放置空格.
  2. 您使用了Name属性而不是IsEnabled属性.

  1. You forgot to put a space between Binding and ElementName.
  2. You used the Name property instead of the IsEnabled property.

您可以将GroupBox的定义更改为以下内容:

You can change the definition of your GroupBox to something like the following:

<GroupBox Header="SWG_ProductType" IsEnabled="{Binding ElementName=Typ1, Path =IsChecked}" Grid.Row="3" ...>


这篇关于根据复选框状态启用或禁用组框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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