How do you style the close button in Docking Windows?

Docking/MDI for WPF Forum

Posted 8 years ago by Doug Beck
Version: 16.1.0631
Avatar

In my product, we have several close buttons which all have a red background. I'd like to style the close buttons in the Document Windows as red as well, but I can't figure out how. I imagine it is easy, but can you help me with this?

Comments (4)

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Doug,

You'd probably need to clone and update the default AdvancedTabItem style and make a new one whose Template had the button alteration.  You could assign the resulting Style to the TabbedMdiHost.TabItemContainerStyle property.  The default Style for that property looks like this and inherits the default AdvancedTabItem control Template:

<Style TargetType="docking:AdvancedTabItem">
	<Setter Property="Header" Value="{Binding TabTextResolved}" />
	<Setter Property="HeaderTemplate">
		<Setter.Value>
			<DataTemplate>
				<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
			</DataTemplate>
		</Setter.Value>
	</Setter>
</Style>

To sum up, you'd need to take the XAML above, add a new Template Setter with an altered ControlTemplate that has your close button changes, and put the Style in the TabbedMdiHost.TabItemContainerStyle property.

Your company has licensed WPF Studio so you can have whoever is listed on the Actipro account get the 2016.1 default styles/templates for you.


Actipro Software Support

Posted 8 years ago by Doug Beck
Avatar

I was able to do what I wanted by overriding the CloseButtonContentTemplate. This seems simpler than your solution although I believe your method would be more flexible.  

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

That might work ok for your needs.  Just keep in mind that that particular template is for the content of the button and doesn't control any chrome (borders, padding, etc.) it might have.


Actipro Software Support

Posted 8 years ago by Doug Beck
Avatar

Good point. For me, this works but in general restyling the button requires your approach. 

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.