简体   繁体   中英

How can I make a WPF window look like a Winforms window?

I am in the process of transforming a UI from winforms to WPF. Previously, selecting a tree view would just show a different winform page based on the tree view item selected. Now, I have inserted a WPF DockPanel and every time a treeview item is selected a different winformhost element gets added to the WPF DockPanel.

When I was running on winforms my UI looked like this: 在此处输入图片说明

Now when I run my application with my WPF DockPanel with the WinformHostElements my UI looks like: 在此处输入图片说明

Is there a way for me to apply a style to the WPF DockPanel that looks similar to the winform controls?

(This is only while I finish converting all winform elements to WPF elements.)

Transforming between WinForms and WPF is far from easy. The issue is that XAML and WPF/UWP were designed with the MVVM pattern in mind. While you can use other Design patterns, doing so misses about 90% of the XAMLs power and runs into issues at every other turn. I wrote a intro into MVVM a few years back: https://social.msdn.microsoft.com/Forums/vstudio/en-US/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2/lets-talk-about-mvvm?forum=wpf

What you have right now might be suiteable classes for the Model part of MVVM. But maybe converions is unessesary: For backwards compatibility (and to fill some gaps), WPF does have a way to host WindowsForm era elements: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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