当前位置: 代码迷 >> Windows Mobile >> 怎么在后台修改gird的背景
  详细解决方案

怎么在后台修改gird的背景

热度:13   发布时间:2016-04-25 07:26:57.0
如何在后台修改gird的背景
假设前台有这么一个grid
如何在后台修改他的背景
<Grid x:Name="LayoutRootPivot">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Images/Background.jpg"/>
        </Grid.Background>

------解决方案--------------------

private void button1_Click(object sender, RoutedEventArgs e)
        {
            gridName.Background = new SolidColorBrush(Colors.Blue);
        }

------解决方案--------------------

grid.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri("/Images/test.jpg", UriKind.Relative)) };

BitmapImage需要引用命名空间