public LuaForm()
        {
            InitializeComponent();
            LuaEngine luaEngine = LuaEngine.Instance;

            if (FirstInit)
            {
                mainPage   = true;
                luaContext = LuaContext.CreateLuaContext(this);
                luaEngine.Startup();
                luaId = luaEngine.GetMainForm();
                String initUI = luaEngine.GetMainUI();
                if (initUI != "")
                {
                    LuaViewInflator inflater = new LuaViewInflator(luaContext);
                    this.view = inflater.ParseFile(initUI, null);
                    Content   = view.GetView();
                }
                else
                {
                    luaEngine.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_CREATE, luaContext);
                }
            }
            else
            {
                luaContext = ContextQueue.Dequeue();
            }
        }
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     LuaForm.navService = NavigationService;
     LuaForm.activeForm = this;
     if (FirstInit)
     {
         FirstInit = false;
     }
     else if (!mainPage)
     {
         luaId = NavigationContext.QueryString["luaId"];
         String initUI = NavigationContext.QueryString["ui"];
         if (initUI != "")
         {
             LuaViewInflator inflater = new LuaViewInflator(luaContext);
             this.view = inflater.ParseFile(initUI, null);
             Content   = view.GetView();
         }
         else
         {
             LuaEngine.Instance.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_CREATE, luaContext);
         }
     }
     LuaEngine.Instance.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_RESUME, luaContext);
 }
        public void SetViewXML(String xml)
        {
            LuaViewInflator inflater = new LuaViewInflator(luaContext);

            view    = inflater.ParseFile(xml, null);
            Content = view.GetView();
        }