Silverlight 4 - 使用App.xaml动态加载XAP作为页面更改(App)Application.Current ..为什么?

时间:2011-04-06 22:41:08

标签: c# silverlight prism mef xap

我决定不使用MEF / Prism方法将XAP文件加载到我正在构建的主Silverlight容器应用程序中。

我有1个Master Silverlight应用程序,以及2个将要加载的应用程序。 我的加载代码工作正常,唯一的问题是,当我加载XAP应用程序时,我想加载App.xaml应用程序上下文,因为这是我正在播放我已经构建的IApplication接口。

 public partial class AAApp : IApplication
    {

        #region IApplication Members

        private object userContext;
        private List<Silverlight.Common.Classes.ApplicationMenuItem> menuItemsList;
        private Silverlight.Common.Controls.ApplicationMaster applicationMaster;

        public object UserContext
        {
            get
            {
                return userContext;
            }
            set{
                userContext = value;
            }
        }

        public List<Silverlight.Common.Classes.ApplicationMenuItem> MenuItemsList
        {
            get
            {
                return menuItemsList;
            }
            set
            {
                menuItemsList = value;
            }
        }

        public string ApplicationName
        {
            get { return "Application Manager"; }
        }

        public string ApplicationVersion
        {
            get { return "Version 0.1"; }
        }

        public Guid GUID
        {
            get { return new Guid("{ACD4793E-47D8-4DB7-9A32-FDB9DD6CAFD2}"); }
        }

        public bool IsFullScreen
        {
            get { return false; }
        }

        public Silverlight.Common.Controls.ApplicationMaster MasterControl
        {
            get
            {
                return applicationMaster;
            }
            set
            {
                applicationMaster = value;
            }
        }

        public bool IntialiseApp()
        {

            applicationMaster = new Silverlight.Common.Controls.ApplicationMaster();
            applicationMaster.SetApplicationContent(new MainPage());

            return true;

        }

        public bool CloseApp()
        {
            return true;
        }

        #endregion
    }

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="Test.Application.ApplicationManager.AAApp"
             >
    <Application.Resources>

    </Application.Resources>
</Application>

我面临的问题是当我动态加载AAApp到我的主Silverlight应用程序时,我的(应用程序)Application.Current正在更改为XAP我在AAApp上下文中加载。

有没有人遇到过这个问题,并且知道这个问题。

我使用(App)Application.Current很多来为我的应用程序存储全局变量等,并且随着这种变化,它会打破一切。

由于

0 个答案:

没有答案
相关问题