如何使用后面的一个代码使用多个xaml文件 [英] How to use multiple xaml files with one code behind

查看:102
本文介绍了如何使用后面的一个代码使用多个xaml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一种可以自动检测当前计算机的渲染能力然后决定加载哪个GUI文件的软件.此时,我必须创建以下文件:

1. HighResGUI.xaml + HighResGUI.xaml.cs

2. LowResGUI.xaml + LowResGUI.xaml.cs

HighResGUI.xaml.cs和LowResGUI.xaml.cs都是相同的,只是xaml具有不同的样式(由于当前计算机的渲染功能).目前,这可以解决我的问题.但是,当我想修改一个xaml.cs代码时,必须对高和低执行两次.

所以我的问题是,如何才能将这两个不同的界面(HighResGUI.xaml + LowResGUI.xaml)结合起来,并且仅使用一个后面的代码,例如common.xaml.cs?
谢谢,

Anh

Hi all,

I am developing a SW that can automatically detect the render ability of current machine then decide what GUI file is loaded. At this time, I have to create these files:

1. HighResGUI.xaml + HighResGUI.xaml.cs

2. LowResGUI.xaml + LowResGUI.xaml.cs

Both HighResGUI.xaml.cs and LowResGUI.xaml.cs are the same, only the xaml has different styles (due to the render capability of the current machine). This can solve my problem, at this time. However, when I want to modify one xaml.cs code, I have to do it twice for both High and Low.

So my question is, how can I combine these two different interface (HighResGUI.xaml+ LowResGUI.xaml) and use only one code behind, for example common.xaml.cs?

Thanks,

Anh

推荐答案

我认为您会发现这篇文章很有帮助:

在WPF中创建皮肤用户界面 [
I think you''ll find this article helpful:

Creating a Skinned User Interface in WPF[^]


这篇关于如何使用后面的一个代码使用多个xaml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆