1

我决定不使用 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 应用程序中时,我的 (App)Application.Current 正在更改为我在 AAApp 上下文中加载的 XAP。

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

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

谢谢

4

0 回答 0