[英]WPF InitializeComponent is not recognized
Completely new to WPF and following a Microsoft walkthrough which asked to replace the XML with the following: WPF完全陌生,并且遵循Microsoft演练的要求,将XML替换为以下内容:
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Northwind Orders" Height="335" Width="425"
Name="OrdersWindow" Loaded="Window1_Loaded">
<Grid Name="orderItemsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="258*"/>
<ColumnDefinition Width="161*"/>
</Grid.ColumnDefinitions>
<ComboBox DisplayMemberPath="OrderID" ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="true"
Height="23" Margin="92,12,37.703,0" Name="comboBoxOrder" VerticalAlignment="Top"/>
<DataGrid ItemsSource="{Binding Path=Order_Details}"
CanUserAddRows="False" CanUserDeleteRows="False"
Name="orderItemsDataGrid" Margin="34,46,34.4,49.6"
AutoGenerateColumns="False" Grid.ColumnSpan="2">
<DataGrid.Columns>
<DataGridTextColumn Header="Product" Binding="{Binding ProductID, Mode=OneWay}" />
<DataGridTextColumn Header="Quantity" Binding="{Binding Quantity, Mode=TwoWay}" />
<DataGridTextColumn Header="Price" Binding="{Binding UnitPrice, Mode=TwoWay}" />
<DataGridTextColumn Header="Discount" Binding="{Binding Discount, Mode=TwoWay}" />
</DataGrid.Columns>
</DataGrid>
<Label Height="28" Margin="34,12,0,0" Name="orderLabel" VerticalAlignment="Top"
HorizontalAlignment="Left" Width="65">Order:</Label>
<StackPanel Name="Buttons" Orientation="Horizontal" HorizontalAlignment="Right"
Height="40" Margin="0,261,22.4,4.6" Grid.ColumnSpan="2">
<Button Height="23" HorizontalAlignment="Right" Margin="0,0,12,12"
Name="buttonSave" VerticalAlignment="Bottom" Width="75"
Click="buttonSaveChanges_Click">Save Changes
</Button>
<Button Height="23" Margin="0,0,12,12"
Name="buttonClose" VerticalAlignment="Bottom" Width="75"
Click="buttonClose_Click">Close</Button>
</StackPanel>
</Grid>
</Window>
So I replaced it but now if I go to the file MainWindow.xmal.cs
the code for InitializeComponent();
所以我替换了它,但是现在如果我去MainWindow.xmal.cs
文件,则InitializeComponent();
的代码InitializeComponent();
is being highlighted as not existing. 被突出显示为不存在。
Why is this and how do I correct it? 为什么会这样,我该如何纠正?
You must match the x:Class="Window1"
in XAML with code behind class class MainWindow
. 您必须将XAML中的x:Class="Window1"
与class MainWindow
后面的代码进行匹配。
Change the XAML from x:Class="Window1"
to x:Class="NorthwindClient.MainWindow"
将XAML从x:Class="Window1"
更改为x:Class="NorthwindClient.MainWindow"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.