如何在Windows窗体中应用.xaml文件 [英] How to apply .xaml file in windows form
本文介绍了如何在Windows窗体中应用.xaml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Windows窗体中应用主题文件,但我不能。当我使用下面的代码时,我得到错误,因为没有System.Windows.Application
I need to apply theme file in windows form but I can't. When I use the code below I get error because there is no System.Windows.Application
StreamResourceInfo sri = System.Windows.Application.GetResourceStream(
new Uri("App.xaml", UriKind.Relative));
var resources = (System.Windows.ResourceDictionary)Load(sri.Stream);
var app = new System.Windows.Application();
app.Resources.MergedDictionaries.Add(resources);
谢谢
Thank you
推荐答案
Windows窗体和WPF是两种截然不同的技术。 你不能混合搭配它们。 但是,您可以在Windows窗体控件中托管WPF控件(反之亦然)。 有关更多信息,请参阅以下链接:
- 在Windows窗体中托管WPF复合控件 [ ^ ]
- 在WPF中隐藏Windows窗体控件 [ ^ ]
Windows Forms and WPF are two distinct technologies. You can't mix and match them. However, you can host a WPF control in a Windows Forms control (and vice-versa). See these links for more informarion:
- Hosting a WPF Composite Control in Windows Forms[^]
- Hosting a Windows Forms Control in WPF[^]
这篇关于如何在Windows窗体中应用.xaml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文