Shashank Shashank - 1 year ago 202
C# Question

how to set background image on grid in wpf using C#

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

Can anybody tell me how to do this?

thanks in advance
shashank

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download