2014-02-25 48 views
9

我對WP應用程序很陌生,不知道如何設置文件中的back-ground圖片,以供整個應用程序在Windows Phone 8應用程序中使用。直到現在,我已經放置了一些controls,但未能設置背景圖像。我看過一些材料,但沒有工作。任何幫助將不勝感激 !如何在Windows Phone 8中設置背景圖片?

回答

27

您可以添加使用Image作爲背景的Common Grid Style並將其置於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> 
+1

它的工作! :) –

3

我在我的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 
    } 
};