我的C#代码有效,但是XAML代码不工作......我不知道我犯了什么错误。我是XAML的新手,我尝试去学习它。当我删除该代码:为什么我的XAML代码没有运行?
的KeyDown = “HandleKeyDown”
初始化= “MainWindow_Initilized” 背景= “暗灰”>
那么就没有误差。
<Window x:Class="Tetris.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="570" Width="525">
KeyDown = "HandleKeyDown"
Initialized = "MainWindow_Initilized" Background ="DimGray">
<DockPanel LastChildFill="False">
<StackPanel DockPanel.Dock="Right" Width="127">
<Label Content="Label" Height="56" Name="Scores" FontSize="28" FontWeight="Bold" />
<Label Content="Label" Height="56" Name="Lines" FontSize="28" FontWeight="Bold"/>
</StackPanel>
<Grid Name="MainGrid" Height="500" Width="250">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</DockPanel>
</Window>
但我需要的代码为PROGRAMM。 – user3013837
'为什么我的XAML代码没有运行? - 因为XAML是一种声明性语言,而不是必要的语言。 XAML代码不会“运行”。它被读取,就像它是数据一样,并被转换成一个对象图。 –
究竟发生了什么,您预期会发生什么?有什么异常?编译器错误?准确的信息是什么? –