2012-05-29 24 views
0

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

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

你命名“backgroungimages”文件夹错误的,或者是只错在XAML?什么是构建行动http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action –

+2

不!背景图片目录是好的,因为该目录正在为其他页面工作。并且构建操作也被设置为资源。我发现几乎没有像谷歌解决方案,重新启动VS或清理并再次构建解决方案......但他们没有为我工作! 谢谢你的建议!参考是一个很好的! – Mushfiq

回答

1
Set grid background to 

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

谢谢! 完成了! – Mushfiq