假设前台有这么一个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需要引用命名空间