【发布时间】:2016-08-10 12:06:01
【问题描述】:
如何为 Telerik 分组框的标题添加颜色?
<StackPanel Orientation="Vertical">
<telerik:GroupBox Header="Demo">
<StackPanel Orientation="Vertical">
【问题讨论】:
标签: wpf xaml silverlight telerik
如何为 Telerik 分组框的标题添加颜色?
<StackPanel Orientation="Vertical">
<telerik:GroupBox Header="Demo">
<StackPanel Orientation="Vertical">
【问题讨论】:
标签: wpf xaml silverlight telerik
有一些内置主题可以直接应用于 GroupBox 控件。它们提供了一些基本的样式选项,您可能会找到最适合您需要的样式。
内置主题:http://docs.telerik.com/devtools/winforms/panels-and-labels/groupbox/themes
但是,如果您真的不想使用内置主题而只想自定义 UI,那么您应该查看 Telerik Presentation Framework (TPF) 并设计和实现您自己的 GroupBox 控件。
更改 GroupBox 标题颜色
((FillPrimitive)this.radGroupBox1.GroupBoxElement.Children[1].Children[0]).BackColor = Color.Red;
((FillPrimitive)this.radGroupBox1.GroupBoxElement.Children[1].Children[0]).BackColor2 = Color.Yellow;
((FillPrimitive)this.radGroupBox1.GroupBoxElement.Children[1].Children[0]).GradientStyle = Telerik.WinControls.Gradien
有关 TPF 的更多详细信息: http://docs.telerik.com/devtools/winforms/panels-and-labels/groupbox/advanced/tpf-structure
【讨论】:
正如 WoodKiddy 之前提到的,建议使用 c# 版本 - 以编程方式设置颜色。 看来 Telerik 团队自己在这里也提出了同样的建议:
This question seems similiar to yours
我不太习惯 xaml 结构,再次开发团队建议使用 c# 方法。但这可能会带来一些运气:
<Style x:Key="MyGroupBoxStyle" TargetType="{x:Type GroupBox}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="Black" FontWeight="Bold"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
祝你好运!
【讨论】: