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

时间:2013-08-17 02:19:05

标签: c# xaml windows-phone-8

我收到了这个错误:

  

错误:第17行第6位的“网格”开始标记与“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>

1 个答案:

答案 0 :(得分:1)

我将您的代码添加到我的测试应用程序中,没有发现此类错误。只是尝试正确对齐标记并重建您的应用。