C# 如何在Windows Phone 8中设置背景图像?

C# 如何在Windows Phone 8中设置背景图像?,c#,windows-phone-8,C#,Windows Phone 8,我对WP应用程序非常陌生,不知道如何在app.xaml文件中为WindowsPhone8应用程序中的整个应用程序设置背景图像。到目前为止,我已经在它上面放置了一些控件,但是没有设置背景图像。我看过一些材料,但不起作用。任何帮助都将不胜感激 您可以添加一个使用图像作为背景的通用网格样式,并将其放置在App.xaml.Resources下 <Application.Resources> <Style x:Key="LayoutGridStyle" TargetType="G

我对
WP
应用程序非常陌生,不知道如何在
app.xaml
文件中为
WindowsPhone8
应用程序中的整个应用程序设置
背景图像。到目前为止,我已经在它上面放置了一些
控件
,但是没有设置背景图像。我看过一些材料,但不起作用。任何帮助都将不胜感激

您可以添加一个使用图像作为背景的通用网格样式,并将其放置在App.xaml.Resources下

<Application.Resources>
    <Style x:Key="LayoutGridStyle" TargetType="Grid">
          <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/Assets/bgImage.jpg"/>
            </Setter.Value>
        </Setter>
    </Style>
</Application.Resources>

并将其用于页面的根网格

<Grid x:Name="LayoutRoot"  Style="{StaticResource LayoutGridStyle}">
//Content goes here
</Grid>

//内容在这里

我在app.xaml.cs的InitializePhone应用程序方法中使用了以下内容。其效果是每个页面都有相同的背景图像,页面导航时没有闪烁/空白

 RootFrame = new PhoneApplicationFrame
 {
    Background = new ImageBrush()
    {
       ImageSource = new BitmapImage(new Uri("Assets/Russel_Logo_ep2s.png", UriKind.Relative)),
       Opacity = 0.3,
       Stretch = System.Windows.Media.Stretch.None,
       AlignmentX = AlignmentX.Center,
       AlignmentY = AlignmentY.Center
    }
 };