且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#中实现条件WPF?

更新时间:2023-09-23 09:24:40

您无法在xaml中定义if条件.
但是,您可以将转换器用作解决方法-请参见此处 [ ^ ].
You cannot define if conditions in a xaml.
However, you can use a converter as a workaround - see here[^].


如果是我,我会在xaml中创建标签页,但最初将它们设置为隐藏(或折叠).然后,在后面的代码中(或通过选项卡控件的控制模板中的触发器),我将显示/隐藏相应的页面.
If it were me, I would create the tab pages in xaml, but set them initially to be hidden (or collapsed). And then, in the code behind (or via triggers in the control template for the tab control), I would show/hide the pages as appropriate.


除了JSOP所说的,还要检查一下用户可以很好地控制并识别相似的项目/控件.您甚至可以只创建一个用户控件,并在运行时动态更改内容.
In addition to what JSOP said, examine the user controls very well and identify items/control that are similar. You can even create just one user control and dynamically change the content at run-time.