locked
Global Background Image

    Question

  • Hi guys,

    I´m trying to figure out how to set an Image as a Global background in my App (Visual Basic),

    The methode with adding it to every Frame as a Grid imagesource isn´t ok, the flicker doesn´t look good at all.

    I had found some solutions but they´re all for C++ or C#.

    I just know I need to set in the App.xaml.vb behind the "RootFrame.Background" something.

    Thanks in advance guys

    Wednesday, April 23, 2014 3:58 PM

Answers

  • You can set the Frame's background like so:

                rootFrame.Background = Resources("MyBackgroundBrush")
    

    But that will probably not show up since your pages will generally paint over it. Typically you'd set the brush on your Grids. This shouldn't cause flicker and is the most common way backgrounds are set.
        <Grid Background="{StaticResource MyBackgroundBrush}"/>
    

    In both cases you'll want to define the image in resources and blank it out in high contrast modes.

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Default">
                    <ImageBrush x:Key="MyBackgroundBrush" Stretch="Fill" ImageSource="Assets/gracie.jpg"/>
                </ResourceDictionary>
                <ResourceDictionary x:Key="HighContrast">
                    <SolidColorBrush x:Key="MyBackgroundBrush" Color="{ThemeResource SystemColorWindowColor}" />
                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    

    --Rob

    Wednesday, April 23, 2014 11:15 PM
    Owner