【问题标题】:how to hide systemtray in landscape如何在横向隐藏系统托盘
【发布时间】:2013-09-29 09:17:20
【问题描述】:

如何在windows phone中更改系统托盘纵向显示和横向隐藏?!

我现在有这样的东西,但它不起作用:

void Pregled_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        if (e.Orientation == PageOrientation.PortraitUp)
        {
            SystemTray.IsVisible = true;
        }
        else
        {
            SystemTray.IsVisible = false;
        }
    }

在 xaml 页面上,shell:systemtray.isvisible="true" 它不起作用。如果我从 xaml 中的 systemtray 中删除可见性,则根本不会显示。

我修复了它,这是我的代码中的一个小错误,我不得不使用 PhoneApplicationPage_BeginLayoutChanged 而不是 Pregled_OrientationChanged 我想我可以设置我想要的事件处理程序名称......我的错误。

【问题讨论】:

  • VisualStateManager 中应该有一个名为OrientationStatesVisualStateGroup,您可以在其中根据其横向或纵向状态应用您的可见性更改。
  • 在 xaml 中我没有类似于视觉状态组的东西,我不知道你的意思。我认为上面的这段代码应该可以工作,但它没有。有没有办法改进它,让它工作?!
  • 我刚刚尝试了您的代码,它对我有用...您确定您注册了 Pregled_OrientationChanged 吗?
  • 注册是什么意思,如果我以这种方式编译它,我在 Visual Studio 中没有错误,但如果我在设备或模拟器上旋转我的设备,系统托盘会保持...

标签: xaml windows-phone show-hide system-tray orientation-changes


【解决方案1】:

这段代码让它工作了……

private void PhoneApplicationPage_BeginLayoutChanged (object sender, OrientationChangedEventArgs e)
{
    if (e.Orientation == PageOrientation.PortraitUp)
    {
        SystemTray.IsVisible = true;
    }
    else
    {
        SystemTray.IsVisible = false;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 2011-09-27
    • 2011-07-23
    相关资源
    最近更新 更多