gpt4 book ai didi

c# - XAML 解析异常 - xmlns :x ="http://schemas.microsoft.com/winfx/2006/xaml"

转载 作者:IT王子 更新时间:2023-10-29 04:40:06 30 4
gpt4 key购买 nike

昨晚我在我的 PC 上使用 VS 2010 Ultimate 处理一个 WPF 项目。

我刚刚使用 VS C# 2010 Express 在我的上网本上打开了它。

当我尝试运行它时,我抛出了一个 XAML 解析异常,它告诉我该行:

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

是问题。我看不出它有什么问题,我从未更改过它,看起来它应该是这样。

错误:

'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.

完整的 XAML:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Camera" Height="550" Width="826" Background="#ddd" ResizeMode="NoResize" WindowStyle="None" MouseLeftButtonDown="Window_MouseLeftButtonDown" BorderBrush="#FF8D8D8D" BorderThickness="2" >
<Window.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter
Margin="{TemplateBinding Control.Padding}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
RecognizesAccessKey="True"
Content="{TemplateBinding ContentControl.Content}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid Width="830" Height="510">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="132" />
<ColumnDefinition Width="698*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="29" />
<RowDefinition Height="319" />
<RowDefinition Height="121" />
<RowDefinition Height="16" />
<RowDefinition Height="25*" />
</Grid.RowDefinitions>
<ComboBox Name="PortNames" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" SelectionChanged="PortNames_SelectionChanged" Margin="12,6,0,0" />
<Ellipse Grid.Row="2" Height="120" HorizontalAlignment="Left" Name="ellipse1" StrokeThickness="6" VerticalAlignment="Top" Width="120" MouseLeftButtonDown="ellipse1_MouseLeftButtonDown" Margin="12,0,0,0">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#89FF0000" Offset="0" />
<GradientStop Color="Red" Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
<Ellipse.Stroke>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#FFB10000" Offset="0" />
<GradientStop Color="#83B20707" Offset="0" />
<GradientStop Color="#F7B00000" Offset="1" />
</LinearGradientBrush>
</Ellipse.Stroke>
</Ellipse>
<Button Content="Sync" Height="23" HorizontalAlignment="Left" Margin="57,6,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" Grid.Row="1" />
<Rectangle Height="23" HorizontalAlignment="Left" Margin="12,6,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Fill="Red" Width="39" OpacityMask="#AA000000" Grid.Row="1" />
<ProgressBar Grid.Row="4" Height="19" HorizontalAlignment="Left" Name="progressBar1" VerticalAlignment="Top" Width="120" Margin="12,2,0,0" />
<Rectangle Grid.RowSpan="5" Grid.Column="1" Height="500" Name="rectangle1" Stroke="#aaa" Width="660" Fill="#eee" Margin="12,5,26,5" />
<Button Grid.Column="1" Height="18" HorizontalAlignment="Left" Margin="630,-20,0,0" Name="image1" VerticalAlignment="Top" Width="40" Click="image1_Click"><Image Stretch="Fill" Source="/PhotoProgram;component/Images/Close.png" /></Button>
<Button Grid.Column="1" Height="18" HorizontalAlignment="Left" Margin="587,-20,0,0" Name="minimize" VerticalAlignment="Top" Width="40" Click="minimize_Click"><Image Stretch="Fill" Source="/PhotoProgram;component/Images/Minimize.png" /></Button>
</Grid>

最佳答案

XAMLParseException 是 WPF 中抛出的常见异常。不幸的是,它不是很有用。

为了帮助找出真正的错误是什么,您可以更早地在 Visual Studio 中打开异常报告。默认组合键是 Ctrl + Alt + E。从那里,选中所有框。

现在您的代码中抛出的异常将在调试器中突出显示。

关于c# - XAML 解析异常 - xmlns :x ="http://schemas.microsoft.com/winfx/2006/xaml",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9045378/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com