[Solved] LayoutControlTabGroup set background color

1 Answer 13 Views
LayoutControl
Thomas
Top achievements
Rank 1
Thomas asked on 04 Mar 2026, 01:04 PM

In a RadLayoutControl I use LayoutControlTabGroup.
I can set the background of the Item's but not on the "empty" space, is there some way to do that.

  <telerik:RadLayoutControl >
      <telerik:LayoutControlTabGroup Background="White">
          <telerik:LayoutControlTabGroupItem Header="Tab 1" Background="Red">
              <Button Content="Item 1" />
          </telerik:LayoutControlTabGroupItem>
          <telerik:LayoutControlTabGroupItem Header="Tab 2"  Background="Blue">
              <Button Content="Item 2" />
          </telerik:LayoutControlTabGroupItem>
      </telerik:LayoutControlTabGroup>
  </telerik:RadLayoutControl>

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 04 Mar 2026, 02:44 PM

Hello Thomas,

The background is represented by a Border element inside the default ControlTemplate of the LayoutControlTabGroup element, which has its Background property set to a resource. To change it, you could either extract the ControlTemplate or retrieve the element via code and manually modify it.

With this in mind, you could follow the second suggestion, for which a custom attached property could be introduced, which will subscribe to the Loaded event of the LayoutControlTabGroup and retrieve the Border element via the ChildrenOfType extension method. On the returned element, you could set the Background property to the desired color.

The following code snippets showcase this suggestion's implementation:

<telerik:RadLayoutControl >
	<telerik:LayoutControlTabGroup local:LayoutControlTabGroupExtensions.BackgroundBrush="White">
		<telerik:LayoutControlTabGroupItem Header="Tab 1" Background="Red">
			<Button Content="Item 1" />
		</telerik:LayoutControlTabGroupItem>
		<telerik:LayoutControlTabGroupItem Header="Tab 2"  Background="Blue">
			<Button Content="Item 2" />
		</telerik:LayoutControlTabGroupItem>
	</telerik:LayoutControlTabGroup>
</telerik:RadLayoutControl>
public class LayoutControlTabGroupExtensions
{
    public static SolidColorBrush GetBackgroundBrush(DependencyObject obj)
    {
        return (SolidColorBrush)obj.GetValue(BackgroundBrushProperty);
    }

    public static void SetBackgroundBrush(DependencyObject obj, SolidColorBrush value)
    {
        obj.SetValue(BackgroundBrushProperty, value);
    }

    public static readonly DependencyProperty BackgroundBrushProperty =
		DependencyProperty.RegisterAttached("BackgroundBrush", typeof(SolidColorBrush), typeof(LayoutControlTabGroupExtensions), new PropertyMetadata(Brushes.Black, OnBackgroundBrushChanged));

	private static void OnBackgroundBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
	{
		LayoutControlTabGroup layoutControlTabGroup = (LayoutControlTabGroup)d;

		layoutControlTabGroup.Loaded += LayoutControlTabGroup_Loaded;
	}

	private static void LayoutControlTabGroup_Loaded(object sender, RoutedEventArgs e)
	{
		LayoutControlTabGroup layoutControlTabGroup = (LayoutControlTabGroup)sender;

        Border border = layoutControlTabGroup.ChildrenOfType<Border>().FirstOrDefault();

        if (border != null)
        {
            border.Background = GetBackgroundBrush(layoutControlTabGroup);
		}
	}
}

The produced result is as follows:

With this being said, would it be possible to give this suggestion a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Thomas
Top achievements
Rank 1
commented on 05 Mar 2026, 09:56 AM

Thanks that worked great!

 

Tags
LayoutControl
Asked by
Thomas
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or