在运行时加载 XAML? [英] Loading XAML at runtime?

查看:43
本文介绍了在运行时加载 XAML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先是一些背景知识:我正在开发一个应用程序,我正在尝试遵循 MVVM 约定编写它.我想做的一件事是能够为我的应用程序提供不同的外观".相同的应用程序,但为一个客户端显示一个皮肤",为另一个客户端显示不同的皮肤".

First some background: I'm working on an application and I'm trying to follow MVVM conventions writing it. One thing I'd like to do is to be able to give the application different "skins" to my application. The same application, but show one "skin" for one client and a different "skin" for another.

所以我的问题是:
1. 是否可以在运行时加载 xaml 文件并将其分配"给我的应用程序?
2. xaml 文件可以是驻留在不同文件夹中的外部文件吗?
3. 应用程序是否可以轻松切换到另一个 xaml 文件,还是仅在启动时?

And so my questions are:
1. Is it possible to load a xaml file at run time and "assign" it to my app?
2. Can the xaml file be an external file residing in a different folder?
3. Can the application switch to another xaml file easily, or only at startup time?

那么我应该从哪里开始寻找这方面的信息?哪些 WPF 方法(如果存在)处理此功能?

So where should I start looking at for information on this? Which WPF methods, if they exist, handle this functionality?

谢谢!

我想做的换肤"类型不仅仅是改变我的控件的外观.这个想法是有一个完全不同的用户界面.不同的按钮,不同的布局.有点像该应用的一个版本如何为专家提供完整的功能,而另一个版本则为初学者简化.

the type of "skinning" I'm wanting to do is more than just changing the look of my controls. The idea is having a completely different UI. Different buttons, different layouts. Kinda like how one version of the app would be fully featured for experts and another version would be simplified for beginners.

推荐答案

我认为这对于 XamlReader 来说相当简单,试一试,我自己没有尝试过,但我认为它应该可以工作.

I think this is fairly simple with the XamlReader, give this a shot, didn't try it myself, but I think it should work.

http://blogs.msdn.com/ashish/archive/2007/08/14/dynamically-loading-xaml.aspx

这篇关于在运行时加载 XAML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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