找不到类型 'System.Windows.Controls.Grid' 的模板 属性 'Foreground'
Cannot find the Template Property 'Foreground' on the type 'System.Windows.Controls.Grid'
我正在尝试在选项卡控件的 ControlTemplate 触发器中添加 属性 'Foreground' :
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="Gray" />
<Setter Property="Foreground" TargetName="Panel" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Error Cannot find the Template Property 'Foreground' on the type 'System.Windows.Controls.Grid'.
这里有什么问题?
我通过添加修复了错误:
<Setter Property="TextElement.Foreground" TargetName="Panel" Value="White"></Setter>
所以完整的代码将是:
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="Gray" />
<Setter Property="TextElement.Foreground" TargetName="Panel" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
我正在尝试在选项卡控件的 ControlTemplate 触发器中添加 属性 'Foreground' :
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="Gray" />
<Setter Property="Foreground" TargetName="Panel" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Error Cannot find the Template Property 'Foreground' on the type 'System.Windows.Controls.Grid'.
这里有什么问题?
我通过添加修复了错误:
<Setter Property="TextElement.Foreground" TargetName="Panel" Value="White"></Setter>
所以完整的代码将是:
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="Gray" />
<Setter Property="TextElement.Foreground" TargetName="Panel" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>