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

Baq*_*qvi 9 c# windows-phone-8

我是WP应用程序的新手,不知道如何在应用程序中为整个应用程序设置文件中的back-ground图像.直到现在,我已经放置了一些,但未能设置背景图像.我看过一些材料,但没有用.任何帮助将不胜感激 !app.xamlWindows Phone 8controls

asi*_*tis 27

您可以添加使用Image作为背景的公共网格样式.并将其放在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>
Run Code Online (Sandbox Code Playgroud)

并将其用于页面的根网格.

<Grid x:Name="LayoutRoot"  Style="{StaticResource LayoutGridStyle}">
//Content goes here
</Grid>
Run Code Online (Sandbox Code Playgroud)