为什么我的XAML解析失败(开始标记与结束标记不匹配)

本文关键字:结束 不匹配 开始 XAML 我的 失败 为什么 | 更新日期: 2023-09-27 18:28:10

我收到这个错误:

错误:第17行第6位置的"Grid"起始标记与"phone:PhoneApplicationPage"的结束标记不匹配。

我尝试了很多方法来解决这个错误,但都失败了。请告诉我如何解决这个问题。

我的代码是:

<phone:PhoneApplicationPage
x:Class="wmvplayer.MainPage"
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"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="WMV Player" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>
    <StackPanel Background="Black">
        <!-- To interactively stop, pause, and play the media, the LoadedBehavior 
       property of the MediaElement must be set to "Manual". -->
        <MediaElement Source="media'numbers.wmv" Name="myMediaElement" 
 Width="450" Height="250" Stretch="Fill" 
 MediaOpened="Element_MediaOpened" MediaEnded="Element_MediaEnded"/>
        <StackPanel HorizontalAlignment="Center" Width="450" Orientation="Horizontal">
            <Image Source="play.png" MouseEnter="OnMouseDownPlayMedia" Margin="5" />
            <!-- Pause button. -->
            <Image Source="pause.png" MouseEnter="OnMouseDownPauseMedia" Margin="5" />
            <!-- Stop button. -->
            <Image Source="stop.png" MouseLeave="OnMouseDownStopMedia" Margin="5" />
            <!-- Volume slider. This slider allows a Volume range between 0 and 1. -->
            <TextBlock Foreground="White" VerticalAlignment="Center" Margin="5"  >Volume</TextBlock>
            <Slider Name="volumeSlider" VerticalAlignment="Center" ValueChanged="ChangeMediaVolume" 
   Minimum="0" Maximum="1" Value="0.5" Width="70"/>
            <!-- Volume slider. This slider allows you to change the speed of the media playback. -->
            <TextBlock Foreground="White" Margin="5"  VerticalAlignment="Center">Speed</TextBlock>
            <Slider Name="speedRatioSlider" VerticalAlignment="Center" ValueChanged="ChangeMediaSpeedRatio" 
   Value="1" Width="70" />
            <!-- Seek to slider. Ths slider allows you to jump to different parts of the media playback. -->
            <TextBlock Foreground="White" Margin="5"  VerticalAlignment="Center">Seek To</TextBlock>
            <Slider Name="timelineSlider" Margin="5" ValueChanged="SeekToMediaPosition" Width="70"/>
        </StackPanel>
    </StackPanel>
    </Grid> </phone:PhoneApplicationPage>

为什么我的XAML解析失败(开始标记与结束标记不匹配)

我将您的代码添加到我的测试应用程序中,但没有发现这样的错误。只要试着对标签进行正确的对齐,然后重新构建你的应用程序。