首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么调试器在这里说Frame.Content为空

为什么调试器在这里说Frame.Content为空
EN

Stack Overflow用户
提问于 2017-03-07 07:12:48
回答 1查看 133关注 0票数 0

我已经习惯了WinForms,所以这并不是我期望的那样。在下面的代码中,ActiveView是一个框架,寄存器是页面。我想将注册页面加载到ActiveView中,然后更改按钮上的文本。即使页面加载,调试器也会显示SetCloseButtonText中的ActiveView.Content == null。为什么会这样呢?

代码语言:javascript
复制
private void btnRegister_Click(object sender, RoutedEventArgs e)
        {

            SwapActiveView(Register);
        }

        public void SwapActiveView(Page NewPage)
        {
            if (ActiveView.Content == null || !ActiveView.Content.Equals(NewPage))
            {
                if (ActiveView.Content != null)
                {
                    PreviousViews.Add((Page)ActiveView.Content);
                }
                ActiveView.Content = NewPage;
            }
            else
            {
                ActiveView.Content = NewPage;
            }

            SetCloseButtonText();
        }

        private void SetCloseButtonText()
        {
            if (PreviousViews.Count == 0 && ActiveView.Content == null)
            {
                tbCloseButton.Text = "Close";
            }
            else
            {
                tbCloseButton.Text = "Back";
            }

        }
EN

回答 1

Stack Overflow用户

发布于 2017-03-07 09:52:20

我最终找到了答案。无论您是调用导航函数还是仅更改内容,框架都会异步导航。所以我只需要添加方法,然后调用我的函数。

代码语言:javascript
复制
private void ActiveView_Navigated(object sender, NavigationEventArgs e)
    {
        SetCloseButtonText();
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42637331

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档