wpf C# Windows 窗体和 XAML

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16482288/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:45:58  来源:igfitidea点击:

C# Windows Forms and XAML

c#wpfxaml

提问by user2194683

I would like to know if it is possible to combine XAML with Window Form or reverse. Also I would like to know a good place to learn how to work with both of them.

我想知道是否可以将 XAML 与 Window Form 或反向结合使用。我也想知道一个学习如何与他们一起工作的好地方。

For example I want to make a XAML window on which I want to add a button with an event action wrote in C#.

例如,我想制作一个 XAML 窗口,我想在该窗口上添加一个按钮,其中包含一个用 C# 编写的事件操作。

回答by Erno

Yes this is possible (both ways)

是的,这是可能的(两种方式)

WinForms in WPF

WPF 中的 WinForms

WPF in WinForms

WinForms 中的 WPF

In both cases you add a special control that acts as a host for the other environment.

在这两种情况下,您都添加了一个特殊控件,作为其他环境的宿主。

回答by David

WindowsFormsHostallows you to host a Windows Forms control on a WPF page.

WindowsFormsHost允许您在 WPF 页上托管 Windows 窗体控件。