如何为用户界面控件实现分支逻辑 [英] How to implement branching logic for the user interface controls
问题描述
我正在研究如何控制属性UI屏幕元素,如文本框,如Visible(或ReadOnly),基于用户在同一屏幕下拉列表中选择的选项
。这是’一个简单的示例场景。
让我们假设您的订单实体中有一个GST字段。假设您还有一个Country字段。这两个字段都在OrderDetail屏幕的
上公开为绑定属性。假设Country字段是LightSwitch选择列表,其中包含两个值:Unites States和Canada。
如果用户选择美国,则需要隐藏(或至少禁用)GST字段。
如果用户更改了国家的价值,从美国到加拿大,然后需要显示(或至少启用)GST属性。
需要对屏幕布局进行这些更改,而无需将更改保存到数据库,或者必须刷新屏幕。
推荐答案
嗨罗伯特,
这很容易。当您检测到您感兴趣的属性发生更改时(通过使用INotifyPropertyChanged,通过将EntityProperty强制转换为INotifyPropertyChanged并实现事件处理程序),您可以使用以下代码:
This is quite easy. When you detect a change in the property you're interested in (& I do that by using INotifyPropertyChanged, by casting the EntityProperty to INotifyPropertyChanged & implementing an event handler), you can use teh following code:
Me.FindControl(" NameOfControl")。IsVisible = false(如果你想禁用,则为IsEnabled)
Me.FindControl("NameOfControl").IsVisible = false (or IsEnabled if you want to disable)
你没有提到你是使用VB还是C#,所以我给你VB代码,但C#代码几乎相同,&我不知道你是什么级别的程序员,所以如果你需要更多细节,我现在不知道。
You don't mention whether you use VB or C#, so I gave you VB code, but the C# code is almost identical, & I don't know what level programmer you are, so I don't now if you need more detail.
Yann
这篇关于如何为用户界面控件实现分支逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!