用后台代码来实现对容器背景的切换,用本地图片作为背景。

把需要的图片素材放到Assets文件夹下

前台xaml代码如下:

    <Grid x:Name="gd_backimage">
    </Grid>

就是起了个名字。。。

后台c#代码

ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/sunny.jpg", UriKind.Absolute));
gd_backimage.Background = imageBrush;


 Ok。 



Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐