我在WPF
学习触发器。从这里trigger demo
但是当我编写类似于该教程的代码时,它会显示" 属性键不存在"
我的代码
<Window.Resources>
<Style x:key="ButtonStyle" TargetType="{x:Type Button}">
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Content="My Button" HorizontalAlignment="Left" VerticalAlignment="Top" MaxWidth="100" Padding="6" Margin="8"/>
</Grid>
答案 0 :(得分:3)
x:Key
确保您已包含命名空间&#39; x&#39;
Windows标记中的 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"