【问题标题】:How to globally set an application's background to an image in windows store app?如何将应用程序的背景全局设置为 Windows 商店应用程序中的图像?
【发布时间】:2013-03-03 18:24:29
【问题描述】:

我正在尝试在我的应用程序中将图像设置为背景,现在我知道如何在本地使用将图像设置为背景

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

我怎样才能在全局范围内做到这一点,

【问题讨论】:

    标签: xaml windows-store-apps


    【解决方案1】:

    有两种方法可以做到: 1. 将样式添加到您的资源中,无需名称,因此它将应用于该类型的每个元素:

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

    2。添加带有名称的样式并在需要时应用它

    <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>
    

    【讨论】:

    • 我按照您指定的方式更改了 StandardStyles.xaml 文件中 x:Key="LayoutRootStyle" 中的“背景”属性,非常感谢
    猜你喜欢
    • 2015-12-09
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    • 2021-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多