[英]Add background image to wp8 app
您好,我试图将背景图像添加到我的项目页面之一,我是xmal的新手,我需要一些帮助来了解为什么我在运行模拟器时看不到背景。
<phone:PhoneApplicationPage
x:Class="ipublicSrv.Pages.MusicMenuPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Background>
<ImageBrush ImageSource="C:\Users\lior\Documents\Visual Studio 2013\Projects\IPubProject\ipublicSrv\ipublicSrv\Resources\24796-armin-van-buuren.jpg"
Stretch="UniformToFill" />
</Grid.Background>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="Music Menu" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
</Grid>
</Grid>
</phone:PhoneApplicationPage>
看起来您正在使用计算机中的图像。请在构建类型为Content
项目中添加图像,然后给出正确的路径为:
ImageSource="/Resources/Images/yourImage.png //if you added image in `Resource/Image` folder.
希望对您有所帮助。
检查构建操作是否设置为“内容”。 那可能是造成问题的原因。 并检查您正在使用的图像的路径。 它必须在您的项目中。 理想情况下,在资产文件夹中。 或其他地方。 希望能帮助到你。 干杯。
不要添加您的PC地址。 它不会在模拟器上运行。 由于地址无法解析。 将背景图像添加到资产或解决方案中的任何文件夹中,然后使用
ImageSource = "Assets/background.png"
假设您在Assets
文件夹中有名为background.png
图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.