简体   繁体   English

wpf如何从主视图中临时删除控件并放入新窗口

[英]wpf how to temporary remove a control from the main view and put into a new window

I have WPF application which has a main window that contains panels. 我有WPF应用程序,它的主窗口包含面板。 I want to be able to temporary remove one panel from the main view (after button click) and put it into a new window in full screen mode, and then by Escape key clicked I want the control to go back to the original place in the main window. 我希望能够从主视图中临时删除一个面板(单击按钮后),然后以全屏模式将其放到新窗口中,然后通过单击Escape键,我希望控件返回到原先的位置。主窗口。 I don't know how to remove and save the panel position in order to restore the main view. 我不知道如何删除和保存面板位置以恢复主视图。

Any help would be appreciated! 任何帮助,将不胜感激!

I would simply change the visibility of the panel so that it disappears and duplicate a 2nd one in the new full screen view. 我只需更改面板的可见性,使其消失并在新的全屏视图中复制第二个即可。 That way you can just reverse the process, ie close the full screen, deleting the new copy, and make the original visible again. 这样,您就可以撤消该过程,即关闭全屏显示,删除新副本并再次显示原始副本。 This way you don't have to worry about saving the position. 这样,您不必担心保存职位。

Assumeing you are using the mvvm pattern it is simple. 假设您正在使用mvvm模式,这很简单。 create a new full screen window view , that is bound to the viewmodel of your panel. 创建一个新的全屏窗口视图,该视图绑定到面板的viewmodel。 and you are done! 完成了!

if you don't use mvvm. 如果您不使用mvvm。 stop and learn mvvm. 停下来学习mvvm。

I think you should use MVVM or MVP to construct you WPF Application. 我认为您应该使用MVVM或MVP来构建WPF应用程序。 it's easy if you use MVVM. 如果使用MVVM,这很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM