【问题标题】:cant change background image of an usercontrol in WP7无法更改 WP7 中用户控件的背景图像
【发布时间】:2014-03-31 17:19:29
【问题描述】:

我正在开发一个 Windows Phone 应用程序。我是 WP7 应用程序开发的新手。在我的应用程序中,我使用的是用户控件,并且通过代码中显示的以下过程更改了它的背景图像。但是背景图像没有改变。谁能帮我 ? 这是我的代码 sn-p :

<Grid>
    <Image Source="\assests\backgroungimages\appBackground2.jpg" Stretch="UniformToFill"/>
    <StackPanel x:Name="LayoutRoot"  Width="480" Height="306" Background="Black">
        <TextBlock x:Name="ApplicationTitle" Text="Sign In" Style="{StaticResource PhoneTextNormalStyle}" Foreground="#CBF7FA" FontSize="30"/>
        <toolkit:PhoneTextBox Hint="UserName" Name="txtUsername" Width="auto" HintStyle="{StaticResource HintCustomStyle}"></toolkit:PhoneTextBox>
        <toolkit:PhoneTextBox Hint="Password" Name="txtPassword" Width="auto" HintStyle="{StaticResource HintCustomStyle}"></toolkit:PhoneTextBox>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Button Content="Sign In" Name="btnSignIn" Width="auto" Grid.Column="0" Grid.Row="0">
                <Button.Background>
                    <ImageBrush ImageSource="\assests\backgroungimages\btnImage.jpg" Stretch="UniformToFill"></ImageBrush>
                </Button.Background>
            </Button>
            <Button Content="Cancel" Name="btnCancel" Width="auto" Grid.Column="1" Grid.Row="0">
                <Button.Background>
                    <ImageBrush ImageSource="\assests\backgroungimages\btnImage.jpg" Stretch="UniformToFill"></ImageBrush>
                </Button.Background>
            </Button>
        </Grid>
    </StackPanel>
</Grid>

【问题讨论】:

  • 您是否将“backgroungimages”文件夹命名为错误,还是仅在 xaml 中错误?什么是构建操作windowsphonegeek.com/tips/…
  • 不!背景图像目录没问题,因为该目录适用于其他页面。并且还将构建操作设置为资源。我从谷歌找到了一些解决方案,比如重新启动 VS 或清理并再次构建解决方案......但它们都没有为我工作!感谢您的建议!该参考是一个很好的参考!

标签: silverlight windows-phone-7 grid


【解决方案1】:
Set grid background to  

<Grid.Background>
   <ImageBrush ImageSource="\assests\backgroungimages\appBackground2.jpg"/>
</Grid.Background>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-30
    • 2011-12-04
    • 1970-01-01
    • 2022-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    相关资源
    最近更新 更多