如何修复“ Xaml解析失败”?

时间:2019-05-31 06:04:46

标签: c# visual-studio xaml uwp

我正在使用Visual Studio Enterprise2017。当我尝试在Mobile Emulator上运行UWP项目时,出现“ Xaml解析失败”错误。 当我在“本地计算机”上运行它时,一切正常。从一开始我就没有对xaml标头进行任何更改。谁能帮我吗?

下面显示错误的图像。 https://i.imgur.com/FL3Cr4K.jpg https://i.imgur.com/65A2t9y.jpg

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

    <Grid Padding="10">
        <!--Padding - margines-->
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <!-- * zużywa co dostanie.-->
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0">
            <TextBlock Text="Trener persolany" Style="{ThemeResource CaptionTextBlockStyle}"/>
            <TextBlock Text="Użytkownik" Style="{ThemeResource HeaderTextBlockStyle}"/>
        </StackPanel>
        <StackPanel Grid.Row="1" >
            <ListBox Name="lbxUzytkownicy" HorizontalAlignment="Left" Width="150" Height="200" Margin="10" SelectedIndex="0"/>
            <Button Name="ButtonLoguj" Content="Loguj" Margin="10" Click="Click_Loguj"/>
            <StackPanel>
                <TextBlock Text="Nowy uzytkownik" Margin="10,0,0,5"/>
                <TextBox Name="TextboxNowy" Height="32" Width="138" Margin="10,0,0,0" HorizontalAlignment="Left"/>
                <TextBlock Name="TextboxZlaNazwa" Margin="10,5,0,0" Foreground="Red"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" >
                <Button Name="ButtonUtworz" Content="Dodaj użytkownika" Margin="10" Click="Click_Utworz"/>
                <Button Name="ButtonUsun" Content="Wyczyść listę" Margin="10" Click="Click_Usun"/>
            </StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="2">
            <Button Name="ButtonZakoncz" Margin="10" Content="Zakończ"  Click="Click_Zakoncz" Foreground="Red"/>
        </StackPanel>
    </Grid>
</Page>

2 个答案:

答案 0 :(得分:0)

Well, you need to check your app's target version & Min version first and make sure Mobile Emulator have this SDK version installed. if not, download if from here.

答案 1 :(得分:0)

假设您的Style和ThemeResource定义中未出现其他未显示的错误...

从第一个Grid元素(第11行?)中删除Padding =“ 10”。网格控件不提供填充属性。