Justice
Justice

Reputation: 442

How to globally set an application's background to an image in windows store app?

i'm trying to set an image to the background in my application, now i know how to set background to an image locally using

<Grid> <Grid.Background> <ImageBrush ImageSource="/Assets/Background.png"/> </Grid.Background> </Grid>

How can i do this globally,

Upvotes: 0

Views: 1202

Answers (1)

ixSci
ixSci

Reputation: 13698

There are 2 ways to do it: 1. Add style to your resources without name, so it will apply to every element of that type:

<Page.Resources>
    <Style TargetType="Grid">
        <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/Assets/SplashScreen.png"/>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>

2. Add style with name and apply it whenever you need

<Page.Resources>
<Style x:Key="ImageStyle"  TargetType="Grid">
    <Setter Property="Background">
        <Setter.Value>
            <ImageBrush ImageSource="/Assets/SplashScreen.png"/>
        </Setter.Value>
    </Setter>
</Style>
</Page.Resources>
<Grid Style="{StaticResource ImageStyle}">
</Grid>

Upvotes: 3

Related Questions