我的Windows Store应用程序(涉及c#和XAML)似乎无法加载

本文关键字:加载 XAML Store Windows 应用程序 涉及 我的 | 更新日期: 2023-09-27 17:51:13

所以,我是XAML编程的新手,我刚刚编写了一段只涉及基本内容的代码。我在一个空白页面上放了一个背景图像,还有一些按钮和文本块,但当我执行这个程序时,它只给了我一个空白的黑色屏幕。此外,它也不会在错误列表中显示任何错误。我做错了什么?

<Page
x:Class="App2.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="White">
<Image Source="Assets/test.jpg"/>
<Button  HorizontalAlignment="Left" Margin="861,453,0,0" VerticalAlignment="Top" Width="295" Height="69" BorderThickness="8,10" BorderBrush="#FF7682F7"/>
<Button  HorizontalAlignment="Left" Margin="263,453,0,0" VerticalAlignment="Top" Width="295" Height="69" BorderThickness="8,10" Background="Transparent" BorderBrush="#FF7682F7" Click="Button_Click"/>
<TextBlock HorizontalAlignment="Left" Margin="1213,730,0,10" TextWrapping="Wrap" Text="About us" VerticalAlignment="Center" Height="28" Width="124" FontSize="24" Foreground="#FFA8A5A5" TextAlignment="Center" SelectionHighlightColor="#FF6A34E8"  >
        <TextBlock.DataContext>
            <local:BasicPage1/>
        </TextBlock.DataContext>
    </TextBlock>
</Grid>

我的Windows Store应用程序(涉及c#和XAML)似乎无法加载

由于我无法看到您的完整程序代码,我无法确定,但我打赌您的应用程序正在服务于App.BlankPage1以外的其他视图。这将解释没有错误和空白页。您应该验证您实际上在加载时提供了正确的视图。

试试这个:

<Page
   x:Class="App2.BlankPage1"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="using:App2"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d">
<Grid Background="White">
 <Image Source="Assets/test.jpg"/>
 <Button  Content="Button Test" Width="295" Height="69"/>
 <Button  Content="Button Test 2" Margin="263,453,0,0" Width="295" Height="69" Click="Button_Click"/>
 <TextBlock HorizontalAlignment="Left" Margin="1213,730,0,10" TextWrapping="Wrap" Text="About us" VerticalAlignment="Center" Height="28" Width="124" FontSize="24" Foreground="#FFA8A5A5" TextAlignment="Center" SelectionHighlightColor="#FF6A34E8"/>
</Grid>

希望帮助!问候!

好的,问题显然解决了,但我不知道如何解决。我把程序发给了一个朋友,他帮我修改了,我写的代码连一个字母都没改。他说我必须在后台申请"send to back",但这对我来说没有意义。另外,我甚至尝试在另一个程序中这样做,即将背景图像发送到后台,但在我的情况下,它也不起作用。