Window 已加载事件处理程序:"Ensure Event Failed"
Window Loaded event handler: "Ensure Event Failed"
我正在尝试执行为 window 加载添加事件处理程序的简单任务。我正在使用 visual studio 2017。当我键入 Loaded=""
并使用 IntelliSense 添加新的事件处理程序时,我收到错误消息 "Ensure Event Failed" 而没有其他信息。怎么了?
XAML:
<Window x:Class="MLD_UI_1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MLD_UI_1"
mc:Ignorable="d"
Title="MainWindow" Height="350" MinHeight="700" Width="525" MinWidth="1050"
Loaded="">
<Grid Background="{StaticResource MainBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*" MinHeight="80"/>
<RowDefinition Height="200"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*" MinWidth="100"/>
<ColumnDefinition Width="*" MinWidth="100"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Border BorderThickness="2 2 1 2" BorderBrush="Black" Grid.Column="1" Grid.Row="1" Background="{StaticResource UvGradientBrush}" CornerRadius="5 0 0 5"/>
<Border BorderThickness="1 2 2 2" BorderBrush="Black" Grid.Column="2" Grid.Row="1" Background="{StaticResource IrGradientBrush}" CornerRadius="0 5 5 0"/>
<Border BorderThickness="2 2 1 2" BorderBrush="Black" Grid.Column="1" Grid.Row="3" Background="{StaticResource GradientBrush}" CornerRadius="5 0 0 5"/>
<Border BorderThickness="1 2 2 2" BorderBrush="Black" Grid.Column="2" Grid.Row="3" Background="{StaticResource GradientBrush}" CornerRadius="0 5 5 0"/>
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" Margin="10 0 10 0">
<TextBlock Text="UV" FontFamily="Tahoma" Foreground="White" VerticalAlignment="Center" FontSize="20"/>
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="1" Orientation="Horizontal" Margin="10 0 10 0">
<TextBlock Text="IR" FontFamily="Tahoma" Foreground="White" VerticalAlignment="Center" FontSize="20"/>
</StackPanel>
<Image x:Name="imagePane1" Grid.Column="1" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Stretch" Margin="2 2 2 2"/>
<Image x:Name="imagePane2" Grid.Column="2" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Stretch" Margin="2 2 2 2"/>
</Grid>
</Window>
x:Class中的命名空间不正确;它与我后面代码中的命名空间不匹配:
将 x:Class="MLD_UI_1.MainWindow"
更改为 x:Class="MLD_UI_2.MainWindow"
修复了所有问题。
我正在尝试执行为 window 加载添加事件处理程序的简单任务。我正在使用 visual studio 2017。当我键入 Loaded=""
并使用 IntelliSense 添加新的事件处理程序时,我收到错误消息 "Ensure Event Failed" 而没有其他信息。怎么了?
XAML:
<Window x:Class="MLD_UI_1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MLD_UI_1"
mc:Ignorable="d"
Title="MainWindow" Height="350" MinHeight="700" Width="525" MinWidth="1050"
Loaded="">
<Grid Background="{StaticResource MainBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*" MinHeight="80"/>
<RowDefinition Height="200"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*" MinWidth="100"/>
<ColumnDefinition Width="*" MinWidth="100"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Border BorderThickness="2 2 1 2" BorderBrush="Black" Grid.Column="1" Grid.Row="1" Background="{StaticResource UvGradientBrush}" CornerRadius="5 0 0 5"/>
<Border BorderThickness="1 2 2 2" BorderBrush="Black" Grid.Column="2" Grid.Row="1" Background="{StaticResource IrGradientBrush}" CornerRadius="0 5 5 0"/>
<Border BorderThickness="2 2 1 2" BorderBrush="Black" Grid.Column="1" Grid.Row="3" Background="{StaticResource GradientBrush}" CornerRadius="5 0 0 5"/>
<Border BorderThickness="1 2 2 2" BorderBrush="Black" Grid.Column="2" Grid.Row="3" Background="{StaticResource GradientBrush}" CornerRadius="0 5 5 0"/>
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" Margin="10 0 10 0">
<TextBlock Text="UV" FontFamily="Tahoma" Foreground="White" VerticalAlignment="Center" FontSize="20"/>
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="1" Orientation="Horizontal" Margin="10 0 10 0">
<TextBlock Text="IR" FontFamily="Tahoma" Foreground="White" VerticalAlignment="Center" FontSize="20"/>
</StackPanel>
<Image x:Name="imagePane1" Grid.Column="1" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Stretch" Margin="2 2 2 2"/>
<Image x:Name="imagePane2" Grid.Column="2" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Stretch" Margin="2 2 2 2"/>
</Grid>
</Window>
x:Class中的命名空间不正确;它与我后面代码中的命名空间不匹配:
将 x:Class="MLD_UI_1.MainWindow"
更改为 x:Class="MLD_UI_2.MainWindow"
修复了所有问题。