在WP8 / 8.1 Silverlight上显示SystemTray背后的内容(带有可见和透明SystemTray的全屏幕背景)

时间:2014-07-29 15:41:42

标签: silverlight windows-phone-8 windows-phone-8.1

我的问题是针对Windows Phone 8 / 8.1 Silverlight。

我尝试将全屏背景应用于PhoneApplicationPage,但是当我这样做时,SystemTray会阻止该视图。

我想要达到的目标是:

Default office app on WP8 Silverlight

如您所见,Windows Phone 8(模拟器)上的默认Office应用程序具有透明背景和背后的办公室徽标。我怎样才能做到这一点?

我不想隐藏SystemTray,因为这对用户来说非常不方便。

我已经浏览了MSDN博客上的this文章,但它处理的是 Universal Apps ,因此提到的API不可用。

3 个答案:

答案 0 :(得分:1)

你能做的是

  1. 0,-32,0,0的保证金应用于LayoutRoot网格的顶部。
  2. 32的正边距添加到第一个子元素的现有上边距(以平衡第1步)。
  3. 在页面的SystemTray.Opacity = 0.001事件中设置OnLoaded(请参阅 edit0 ),以使SystemTray透明。
  4. 这将使整个屏幕网格向上移动(并隐藏在SystemTray后面)。然后将SystemTray的不透明度设置为0.001使背景透明。

    部分代码:

      

    第1步& 2

    <!--LayoutRoot is the root grid where all page content is placed-->
    
    <Grid x:Name="LayoutRoot"
          Background="Transparent"
    
          Margin="0,-32,0,0"> <!-- Step 1 -->
    
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Rectangle Grid.Row="0" Grid.RowSpan="2">
            <Rectangle.Fill>
                <ImageBrush ImageSource="/Assets/SampleImage.png" />
            </Rectangle.Fill>
        </Rectangle>
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0"
    
                    Margin="12,49,0,28"> <!--Step 2. (default Margin="12,17,0,28")-->
    
            <TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock Text="lel k"
                       Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>
        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel"
              Grid.Row="1"
              Margin="12,0,12,0">
        </Grid>
    </Grid>
    
      

    第3步

    public partial class Page1: PhoneApplicationPage
    {
        // Constructor
        public Page1()
        {
            InitializeComponent();
            Loaded += Page1_Loaded;
            //...
        }
    
        void Page1_Loaded(object sender, RoutedEventArgs e)
        {
            SystemTray.Opacity = 0.001; // see edit0
        }
    }
    

    完成了! 快乐编码:)

    <强> edit0:

    似乎设置SystemTray.Opacity = 0.0隐藏电池指示灯移动电话信号。将其更改为SystemTray.Opacity = 0.001可解决问题。

答案 1 :(得分:1)

关于将应用主题扩展到系统托盘中,有两篇很棒的博客文章(非常简陋的吹嘘):

要完成您想要的操作,只需将SystemTray的不透明度更改为小于1的任何值。这样做会将所有内容转移到托盘中。从那里你可以使用背景或不透明度来支持你想要的颜色。如果您只是希望它完全透明,请将不透明度设置为0.但是这将具有adverse effect on Windows Phone 8.1

答案 2 :(得分:-1)

Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow)