更好的方式来设置得比绑定类在WPF选择器控制的控制的内容?绑定、方式、选择器、内容

2023-09-05 00:39:29 作者:妞给爷站住

我有一个应用程序被分成4个小组。有一个主绘图区,一个顶板,左边的菜单面板,和一个右子菜单面板如在下面的图片。子菜单的内容由所选内容上方菜单按钮决定,子菜单中的内容是由选定的内容右侧的菜单来决定。

I have an app that is split into 4 panels. There is a main drawing area, a top panel, a left menu panel, and a right sub menu panel as in the picture below. The content of the sub menu is determined by what top-menu button is selected, and the content of the sub-menu is determined by what right menu is selected.

例如,这是网络设计和测试(在扩展第一个按钮)被点击时显示的内容。当测试2(上膨胀第二按钮)被点击时,应该有一组不同的按钮在右侧面板

For example this is what is displayed when Network Design and test (first button on expander) is clicked. When test2 (second button on expander) is clicked, there should be a different set of buttons in the right hand panel.

我不使用,因为与地图上的性能问题标签控制,有10000潜力图形对象已经我不想去了8乘以这个数字。

I'm not using tab control because of performance issues with the map, with 10,000+ potential graphics objects already I don't want to go multiplying that number by 8.

我目前正在做它在这篇文章中指出:

I'm currently doing it as stated in this post:

Updating与不同的内容在按钮点击声在WPF 一个ListBox

Updating a ListBox with different Content On Button Clicks in WPF

这曾极大迄今... L,但每个这样的下拉菜单可以有多达8种选择,而一些顶级标签有多达8扩展!使用上面的code将采取的工作很多...希望有一种绕了一个更简洁的方式。

This has worked great thus far...l but each of those drop down menus may have as many as 8 options, and some of the top tabs have as many as 8 expanders! Using the above code would take alot of work... hopefully there is a more 'terse' way of going about it.

推荐答案

创建视图的专用视图模型对象。该视图模型应作为一个状态机,针对不同的用户界面的状态。它应该接受命令和PropertyChanges并作为结果,它会计算并改变他的所得物到WPF控件绑定。

Create a dedicated ViewModel object for the view. The ViewModel should act as a state machine for different UI states. It should accept Commands and PropertyChanges and as result it would calculate and change his resulting properties to which WPF controls are bound.

它通常被称为MVVM模式而被广泛应用于在WPF。该模型是原始数据,查看你的控制和视图模型是状态机连接两个。查看例如本文。

It's commonly known as MVVM pattern and is widely used in WPF. The Model is your raw data, the View is your Control and the ViewModel is the state-machine which connects the two. Check out for example this article.