Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 如何设置网格的背景?_Windows Phone 7_Xaml - Fatal编程技术网

Windows phone 7 如何设置网格的背景?

Windows phone 7 如何设置网格的背景?,windows-phone-7,xaml,Windows Phone 7,Xaml,我在玩样式,想设置网格的背景,比如: <Style TargetType="Grid"> <Setter Property="Background" Value="Background.png" /> </Style> 但这不起作用,正确的方法是什么。。。我怎么能像对待css中的类那样处理它,因为我希望它影响每个网格,即包装页面的网格?您可以像这样直接设置后台属性 <Grid x:Name="Co

我在玩样式,想设置网格的背景,比如:

        <Style TargetType="Grid">
            <Setter Property="Background" Value="Background.png" />
        </Style>

但这不起作用,正确的方法是什么。。。我怎么能像对待css中的类那样处理它,因为我希望它影响每个网格,即包装页面的网格?

您可以像这样直接设置后台属性

<Grid x:Name="ContentPanel" Style="{StaticResource GridStyle1}">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/BackgroundImage.png"/>
        </Grid.Background>
</Grid>
如果要创建样式资源,可以这样设置值

<phone:PhoneApplicationPage.Resources>
    <Style x:Key="GridStyle1" TargetType="Grid">
        <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/BackgroundImage.png" Stretch="Fill"/>
            </Setter.Value>
        </Setter>
    </Style>
</phone:PhoneApplicationPage.Resources>

<Grid Style="{StaticResource GridStyle1}"/>

我建议使用Expression Blend来帮助您了解如何使用样式。它将为您生成控件模板,以便您可以查看它们的结构。

您可以像这样直接设置后台属性

<Grid x:Name="ContentPanel" Style="{StaticResource GridStyle1}">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/BackgroundImage.png"/>
        </Grid.Background>
</Grid>
如果要创建样式资源,可以这样设置值

<phone:PhoneApplicationPage.Resources>
    <Style x:Key="GridStyle1" TargetType="Grid">
        <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/BackgroundImage.png" Stretch="Fill"/>
            </Setter.Value>
        </Setter>
    </Style>
</phone:PhoneApplicationPage.Resources>

<Grid Style="{StaticResource GridStyle1}"/>
我建议使用Expression Blend来帮助您了解如何使用样式。它将为您生成控制模板,以便您可以查看它们的结构