【问题标题】:XAMLParseException occurred发生 XAMLParseException
【发布时间】:2015-02-18 02:15:13
【问题描述】:

在我的 XAML 代码中,我遇到了一个奇怪的错误,我不知道如何修复。我收到一条错误消息:

在 PresentationFramework.dll 中发生了“System.Windows.Markup.XamlParseException”类型的第一次机会异常

附加信息:'Verton_For_Windows_Desktop.MainWindow' 的初始化引发了异常。行号“66”和行位置“7”。

这是我的代码:

<Controls:MetroWindow x:Class="Verton_For_Windows_Desktop.MainWindow"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Verton Ai" Height="573.523" Width="358.453" BorderBrush="Black" Background="{x:Null}" GlowBrush="#FF1768FF" WindowTitleBrush="#FF2470FF" TitleForeground="White" Foreground="#FF2470FF" Topmost="True" ShowMaxRestoreButton="False" SaveWindowPosition="True" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" SnapsToDevicePixels="True" SizeToContent="Height">
<Controls:MetroWindow.Resources>
    <Storyboard x:Key="openButton">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="button">
            <EasingDoubleKeyFrame KeyTime="0" Value="44"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="12"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="button">
            <EasingDoubleKeyFrame KeyTime="0" Value="-2"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-2"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Controls:MetroWindow.Resources>
<Controls:MetroWindow.Triggers>
    <EventTrigger RoutedEvent="UIElement.MouseEnter" SourceName="button"/>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard Storyboard="{StaticResource openButton}"/>
    </EventTrigger>
</Controls:MetroWindow.Triggers>
<Grid Background="#FF1768FF">
    <Button x:Name="Button1" HorizontalAlignment="Left" Margin="121,455,0,0" VerticalAlignment="Top" Width="81" Style="{DynamicResource MetroCircleButtonStyle}" Height="81" BorderBrush="White" BorderThickness="2" Foreground="{x:Null}" FontSize="200" FontStyle="Italic" Cursor="Hand" Click="Button_Click" RenderTransformOrigin="-0.119,0.431">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\Blake Weissman\OneDrive\Extra Curricular Stuff\Verton\Verton New\WindowsIcons-master\WindowsPhone\dark\appbar.microphone.png"/>
        </Button.Background>
        <Button.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Button.RenderTransform>
    </Button>
    <TextBox HorizontalAlignment="Left" Height="48" Margin="10,402,0,0" TextWrapping="Wrap" Text="Type Your Command Here, Or Click The Microphone Button To Say Your Command" VerticalAlignment="Top" Width="332" FontSize="15" FontFamily="Segoe UI Light" Background="White" BorderBrush="{x:Null}" Foreground="#FF1768FF" Uid="commandText" IsKeyboardFocusedChanged="TextBox_IsKeyboardFocusedChanged"/>
    <TextBox HorizontalAlignment="Left" Height="374" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="332" Foreground="#FF1768FF" BorderBrush="{x:Null}" FontFamily="Segoe UI Light" FontSize="20"/>
    <Button x:Name="button_Copy2" HorizontalAlignment="Left" Margin="286,480,0,0" VerticalAlignment="Top" Width="66" Style="{DynamicResource MetroCircleButtonStyle}" Height="66" BorderBrush="White" BorderThickness="2" Foreground="{x:Null}" FontSize="200" FontStyle="Italic" Cursor="Hand" Click="Button_Click" RenderTransformOrigin="-0.119,0.431">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\Blake Weissman\OneDrive\Extra Curricular Stuff\Verton\Verton New\WindowsIcons-master\WindowsPhone\dark\appbar.settings.png"/>
        </Button.Background>
        <Button.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Button.RenderTransform>
    </Button>
    <Button x:Name="button_Copy" HorizontalAlignment="Left" Margin="0,480,0,0" VerticalAlignment="Top" Width="66" Style="{DynamicResource MetroCircleButtonStyle}" Height="66" BorderBrush="White" BorderThickness="2" Foreground="{x:Null}" FontSize="200" FontStyle="Italic" Cursor="Hand" Click="Button_Click" RenderTransformOrigin="-0.119,0.431">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\Blake Weissman\OneDrive\Extra Curricular Stuff\Verton\Verton New\WindowsIcons-master\WindowsPhone\dark\appbar.settings.png"/>
        </Button.Background>
        <Button.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Button.RenderTransform>
    </Button>
</Grid>

【问题讨论】:

    标签: c# xaml


    【解决方案1】:

    行号和位置告诉您问题出在哪里。文件的最后一行 - 缺少 Controls:MetroWindow 的结束标记

    【讨论】:

    • 感谢您的回复,我实际上忘记复制并粘贴代码的最后一行,opps。但是,我能够自己弄清楚。再次感谢您的回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多