基于模型中的数据折叠 Silverlight LOB 应用程序中的 UIElements
在表单中,我对返回的每个字段都有一个用户控件。该控件由堆栈面板内的标签和 texblock 组成。该控件是构成我的表单的数据模板的一部分,该表单由包含用户控件的包装面板组成。我的意图是当渲染表单时评估模型中返回的绑定属性,如果它为空,则将控件的可见性设置为折叠。目的是仅在返回数据的表单中呈现字段。环绕面板允许控件保持内联,而不是允许表单中出现过多的空白。
我最初的想法是迭代返回的列表,如果模型中的属性为空,则通过依赖属性将控件的可见性设置为折叠。我在这里担心的是性能,因为某些表单有超过 700 个字段/属性。
我很想知道是否有人做过类似的方法或者他们使用什么方法来控制 UIElements 的可见性
提前感谢您的任何建议
Within a form I have a user control for each field being returned. The control consists of a label and a texblock within a stack panel. This control is part of a datatemplate that makes up my form which is comprised of a wrap panel which contains the user controls. My intent is when the form is rendered to evaluate the bound property returned in my model and if it null set the visibility of the control to collapsed. The intent is to only have fields rendered within the form that has data being returned. The wrap panel allows for the controls to stay inline vs allowing excess white space in the form.
My initial thought was to iterate through the List that is returned and if the property in the model is null set the visibility of the control to collapsed via a dependency property. A concern I have here is with performance as some forms have over 700 fields / properties.
I was curious to learn if anyone has done a similar approach or what approach they used to control the visibility of UIElements
Thanks in advance for any suggestions
我们使用依赖属性来确定控件的可见性。我们与我们的授权库一起执行此操作。因此,在我们的 xaml 中,代码如下所示:
其中 WebUser 是任何经过身份验证的用户,显然会计/财务/管理角色具有更高的权限。
我们已经在一个页面上进行了数十次调用,没有任何问题,但从来没有数百次。可能值得复制/粘贴看看效果如何。
如果值得的话,这是我们的 Auth 库中的可见性属性:
We use Dependency Properties to determine visibility of controls. We do this in concert with our Authorization library. So in our xaml, the code looks something like this:
Where WebUser is any authenticated user, and obviously Accounting/Finance/Admin roles have elevated privilages.
We've done this with dozens of calls on a page without any problem, but never hundreds. Might be worth a copy/paste to see how it goes.
In case it's worthwhile, here's the visibility property in our Auth library: