wpf 如何在 Winforms 中使 UI 具有响应性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22606907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make the UI responsive in Winforms
提问by Vahid
Instead of most of you guys who first learned Winformsthen moved to WPF, I'm the opposite! For some reasons regarding the graphic performance I have to use Winforms. But I'm stuck at the first step. How can I make the UIresponsive like WPF. What is the equivalent of Gridsin Winforms. Any help is highly appreciated.
与你们大多数先学习Winforms然后转向 的人不同WPF,我恰恰相反!由于某些有关图形性能的原因,我必须使用 Winforms。但我被困在第一步。我怎样才能UI像 WPF 一样做出响应。Grids在 Winforms 中相当于什么。任何帮助都受到高度赞赏。
回答by niklon
If by responsive you mean working on all screen resolutions, you can use panels, and dock controls inside. With a correct mix of controls docked in panels, docked in the main form, you can get a nice design which will automatically fit on all screens. You can also use Anchor property to make a control "stick" to for example top right corner(by default it's always top-left). At least that's what I understood from your question.
如果响应式是指在所有屏幕分辨率下工作,您可以在内部使用面板和停靠控件。通过停靠在面板中的控件的正确组合,停靠在主窗体中,您可以获得一个很好的设计,它会自动适合所有屏幕。您还可以使用 Anchor 属性使控件“粘”到例如右上角(默认情况下它始终位于左上角)。至少这是我从你的问题中了解到的。
回答by woutervs
Another option would be using WPF for all your controls and layouting, and then use winforms host in WPF for your CAD application, you will have the benefits of WPF for responsiveness and you will get the performance for drawing with winforms.
另一种选择是将 WPF 用于您的所有控件和布局,然后在 WPF 中为您的 CAD 应用程序使用 winforms 主机,您将获得 WPF 在响应方面的优势,并且您将获得使用 winforms 绘图的性能。

