【发布时间】:2014-02-26 11:29:26
【问题描述】:
我对@987654321@ 应用程序非常陌生,不知道如何在app.xaml 文件中为Windows Phone 8 应用程序中的整个应用程序设置back-ground 图像。到目前为止,我已经在上面放置了一些controls,但未能设置背景图像。我看过一些材料,但没有用。任何帮助将不胜感激!
【问题讨论】:
标签: c# windows-phone-8
我对@987654321@ 应用程序非常陌生,不知道如何在app.xaml 文件中为Windows Phone 8 应用程序中的整个应用程序设置back-ground 图像。到目前为止,我已经在上面放置了一些controls,但未能设置背景图像。我看过一些材料,但没有用。任何帮助将不胜感激!
【问题讨论】:
标签: c# windows-phone-8
您可以添加一个使用 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>
并将其用于页面的根网格。
<Grid x:Name="LayoutRoot" Style="{StaticResource LayoutGridStyle}">
//Content goes here
</Grid>
【讨论】:
我在 app.xaml.cs 的 InitializePhoneApplication 方法中使用以下内容。效果是每个页面都有相同的背景图片,并且页面导航时没有闪烁/空白
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
}
};
【讨论】: