簡體   English   中英

如何在Windows Phone 8中設置背景圖像?

[英]How to set background image in Windows Phone 8?

我是WP應用程序的新手,不知道如何在app.xaml文件中為Windows Phone 8應用程序中的整個應用程序設置back-ground圖像。 直到現在,我已經對它進行了一些controls ,但未能設置背景圖像。 我看過一些材料,但沒有用。 任何幫助將不勝感激 !

您可以添加使用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
    }
 };

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM