WPF完全不熟悉,并且遵循Microsoft演练的要求,将XML替换为以下内容:
Index 12/13/2018 12/14/2018 12/15/2018 12/16/2018 12/17/2018
0 Carol Peter Alice Peter John
1 John Carol null Alice Peter
2 null John null null null
3 null Alice null null null
所以我替换了它,但是现在如果我转到文件<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>
,则MainWindow.xmal.cs
的代码将突出显示为不存在。
这是为什么,我该如何纠正?
答案 0 :(得分:2)
您必须将XAML中的x:Class="Window1"
与类class MainWindow
后面的代码进行匹配。
将XAML从x:Class="Window1"
更改为x:Class="NorthwindClient.MainWindow"