【问题标题】:Adding a background image in Windows Store Apps在 Windows 应用商店应用中添加背景图像
【发布时间】:2014-05-19 17:59:18
【问题描述】:

最近我开始用 XAML 和 C# 制作一个 Windows 应用商店应用程序。不幸的是,我未能添加存储在“/Assets”中的背景 png 图像。到处寻找任何胶水,但我找不到任何有用的东西。

这是我的代码:

<Page
    x:Class="BoggleV01.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BoggleV01"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Margin="160,100" Width="1040">
        <Grid.Background>
            <ImageBrush ImageSource="/Assets/Background.png" Stretch="UniformToFill" />                                            
        </Grid.Background>

        <StackPanel x:Name="levelsStackPanel"  HorizontalAlignment="Left" Height="568" VerticalAlignment="Top" Width="260"/>
        <StackPanel x:Name="playersStackPanel" HorizontalAlignment="Left" Height="568" VerticalAlignment="Top" Width="260" Margin="260,0,0,0"/>
        <StackPanel x:Name="statisticsStackPanel" HorizontalAlignment="Left" Height="568" VerticalAlignment="Top" Width="260" Margin="520,0,0,0"/>
        <StackPanel x:Name="settingsStackPanel" HorizontalAlignment="Left" Height="568" VerticalAlignment="Top" Width="260" Margin="780,0,0,0"/>
    </Grid>
</Page>

【问题讨论】:

    标签: c# xaml background windows-store-apps


    【解决方案1】:

    你可以使用下面提到的代码

    <ImageBrush ImageSource="/Applicationname;component/Assets/Background.png"
                Stretch="UniformToFill" />  
    

    【讨论】:

    • Dhaval,不知何故这并没有解决我的问题,我还尝试了&lt;ImageBrush ImageSource="/BoggleV01;component/Assets/Background.png" Stretch="UniformToFill" /&gt;,以防万一我需要用我的命名空间替换 Applicationname。
    • 你有没有把你的应用程序名替换成应用程序名字符串?
    • 应用程序名称是命名空间,对吗?在那种情况下,是的,我已经做到了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-25
    • 1970-01-01
    • 2015-12-09
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多