RootFrameのBackgroundプロパティにImageBrushのインスタンスを設定することで、背景画像を変更することが出来ます。
private static void SetAppBackground(string imageName) { var app = Application.Current as App; if (app == null) return; var imageBrush = new ImageBrush { ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(imageName, UriKind.Relative)) }; app.RootFrame.Background = imageBrush; } private void button4_Click(object sender, RoutedEventArgs e) { SetAppBackground("SplashScreenImage.jpg"); }
少しサンプルが判りにくいですが、実行前のスクリーンショットです。
こちらが実行後のスクリーンショットです。
SplashScreenImage.jpgがプロジェクトに追加されており、ビルドアクションが「Resource」に設定されているのであれば、以下のようにXAMLで背景画像を設定する事も可能です。
<!--LayoutRoot is the root grid where all page content is placed--> <Grid x:Name="LayoutRoot"> <Grid.Background> <ImageBrush ImageSource="SplashScreenImage.jpg" /> </Grid.Background>