windows phone 学习笔记 四

设置应用程序的背景图片:
private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            SetAppBackground("/ChangeBackground;component/Images/Lighthouse.png");
        }

        private static void SetAppBackground(string imageName)
        {
            var app = Application.Current as App;
            if (app == null)
                return;

            var imageBrush = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri(imageName, UriKind.Relative))
            };
            app.RootFrame.Background = imageBrush;
        }

        private void image2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            SetAppBackground("/ChangeBackground;component/Images/Tulips.jpg");
        }

a   b

原文地址:https://www.cnblogs.com/caodaiming/p/2291669.html