Alex Rivera | Logout

Set background image on grid in WPF using C#

Asked 2010-06-23T10:33:29.530
58

I have a problem: I want to set the image of my grid through code behind.

Can anybody tell me how to do this?

Edit
Report

1 Answer

74

Did you forget the Background Property. The brush should be an ImageBrush whose ImageSource could be set to your image path.

<Grid>
    <Grid.Background>
        <ImageBrush ImageSource="/path/to/image.png" Stretch="UniformToFill"/>
    </Grid.Background>

    <...>
</Grid>
answered 2010-06-23T10:37:22.807

Your Answer