How to modify tittle bar of ToolWindowContainer through style.

Docking/MDI for WPF Forum

Posted 12 years ago by keshav bansal
Version: 11.2.0551
Avatar

Hi,

I erlier posted my question to make changes in TittleBar of toolwindow control for which you suggested to make changes in style ToolWindowContainer. Thanks for your timely reply.

To achieve this is added these button to style x:Key="{x:Type docking:ToolWindowContainer}". But its applied to all toolwindow I use. To solve this I named this style and used it with ToolWindowContainer control. It solves problem partially.

Now it shows these buttons only on Dock mode. I am not able to get these buttons when it’s on Float or Auto hide mode. I can see default buttons like option, auto hide and close but not those I added.

I believe same changes needs to be applied on some other style or somewhere in trigger.

Please help me out so that I can view these buttons in similar way as close button is displayed every time.

Thanks in advance.

Below code section I am using

*********** In XAML*******************

<docking:DockSite Width="242" Height="378" Grid.Column="0" >

  <docking:ToolWindowContainer Style="{StaticResource ToolWindowContainerStyle}">

  <docking:ToolWindow Header="lets doc" />

  </docking:ToolWindowContainer>

</docking:DockSite>

*********** In Style ToolWindowContainerStyle *******************

<DockPanel x:Name="PART_TitleBar" Background="Transparent" Margin="{TemplateBinding Padding}"

LastChildFill="True">

<!-- Buttons -->

<!-- Left Button -->

<Button Margin="20,2,1,2" Width="14" Height="14" x:Name="LeftButton" Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

Focusable="false">

<Path Margin="0,1,0,0" Width="4" Height="7" Fill="Black"

Data="{StaticResource LeftArrow}" HorizontalAlignment="Center" VerticalAlignment="Center" />

</Button>

<!-- Right Button -->

<Button Grid.Column="2" Margin="1,2,1,2" Width="14" Height="14" x:Name="RightButton" Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.CanCloseResolved, Converter={StaticResource BooleanToVisibilityConverter}}" Focusable="false" Padding="2">

<Path Margin="0,1,0,0" Width="4" Height="7" Fill="Black"

Data="{StaticResource RightArrow}" HorizontalAlignment="Center" VerticalAlignment="Center" />

</Button>

<Button x:Name="closeButton" DockPanel.Dock="Right" Padding="2" Focusable="False"

Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

ContentTemplate="{DynamicResource {x:Static themes:SharedResourceKeys.CloseGlyphTemplateKey}}"

Command="{x:Static docking:DockingCommands.CloseWindow}"

CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"

ToolTip="{productsDocking:SRExtension UIToolWindowContainerCloseButtonToolTip}"

Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.CanCloseResolved, Converter={StaticResource BooleanToVisibilityConverter}}"

AutomationProperties.Name="Close" />

<Button x:Name="autoHideButton" DockPanel.Dock="Right" Padding="2" Focusable="False"

Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

ContentTemplate="{DynamicResource {x:Static themes:SharedResourceKeys.UnpinGlyphTemplateKey}}"

Command="{x:Static docking:DockingCommands.ToggleWindowAutoHideState}"

CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"

ToolTip="{productsDocking:SRExtension UIToolWindowContainerAutoHideButtonToolTip}"

Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.CanAutoHideResolved, Converter={StaticResource BooleanToVisibilityConverter}}"

AutomationProperties.Name="Auto-Hide" />

<Button x:Name="maximizeButton" DockPanel.Dock="Right" Padding="2" Focusable="False"

Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

ContentTemplate="{DynamicResource {x:Static themes:SharedResourceKeys.MaximizeGlyphTemplateKey}}"

Command="{x:Static docking:WindowCommands.Maximize}"

CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"

ToolTip="{productsDocking:SRExtension UICommandMaximizeWindowText}"

Visibility="Collapsed" AutomationProperties.Name="Maximize" />

<Button x:Name="restoreButton" DockPanel.Dock="Right" Padding="2" Focusable="False"

Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedButtonBaseOverrideStyleKey}}"

ContentTemplate="{DynamicResource {x:Static themes:SharedResourceKeys.RestoreGlyphTemplateKey}}"

Command="{x:Static docking:WindowCommands.Restore}"

CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"

ToolTip="{productsDocking:SRExtension UICommandRestoreWindowText}"

Visibility="Collapsed" AutomationProperties.Name="Restore" />

<shared:PopupButton x:Name="optionsButton" DockPanel.Dock="Right" DisplayMode="PopupOnly" Padding="2" Focusable="False"

Style="{DynamicResource {x:Static themes:SharedResourceKeys.EmbeddedPopupButtonOverrideStyleKey}}"

PopupIndicatorTemplate="{DynamicResource {x:Static themes:SharedResourceKeys.DropDownArrowGlyphTemplateKey}}"

Command="{x:Static docking:DockingCommands.OpenOptionsMenu}"

CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"

CommandParameter="{x:Static docking:DockingContextMenuType.DockingWindowOptionsButton}"

ToolTip="{productsDocking:SRExtension UIToolWindowContainerOptionsButtonToolTip}"

Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.HasOptionsResolved, Converter={StaticResource BooleanToVisibilityConverter}}"

AutomationProperties.Name="Options" />

<dockingPrimitives:ReverseMeasureDockPanel>

<!-- Title -->

<shared:PixelSnapper DockPanel.Dock="Left" VerticalAlignment="Center">

<TextBlock x:Name="title" Margin="3,1,3,1" TextTrimming="CharacterEllipsis"

Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Title}"

Foreground="{DynamicResource {x:Static themes:AssetResourceKeys.DockingWindowContainerTitleBarForegroundInactiveBrushKey}}"

AutomationProperties.Name="Title" />

</shared:PixelSnapper>

<Image x:Name="contextImage" DockPanel.Dock="Left"

AutomationProperties.Name="Context Image" Stretch="None"

Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.ContextImageSource}"

VerticalAlignment="Center" SnapsToDevicePixels="True" Margin="2,1,2,1" />

</dockingPrimitives:ReverseMeasureDockPanel>

</DockPanel>

Comments (3)

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

Hi Keshav,
We tried adding a button to the title bar of the ToolWindowContainer through style like you described, and it seemed to work fine. It displayed in docked, auto-hide, and floating states. I'm not sure exactly where your problem is coming from.


Actipro Software Support

Posted 12 years ago by keshav bansal
Avatar

Hi,


Thanks for your response.

It works fine only when we keep x:Key="{x:Type docking:ToolWindowContainer}" as it is in default style of ToolWindowContainer.

But it does not work when i rename default style name with my own like x:Key="{x:Type docking:TWC_MyStyle}" and use this named style with control like <docking:ToolWindowContainer Style="{StaticResource TWC_MyStyle}">. In this case it shows button only when toolwindow is docked and on AutoHide and Float mode these button are not visible.

Reason for rename is, i want to use both default and custom style (which i created) for different controls.

Hope i am able to clear my query.

Thanks

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

Hi Keshav,
You can't apply styles on and you should really never reference ToolWindowContainers or any other "container" directly since they are dynamically created and destroyed at runtime. If you want to apply a style to some containers then you should add an implicit style that targets that container type to the Application.Resources or to the DockSite.Resources. There is no way to provide a certain style for some ToolWindowContainers and another style for others within the same DockSite.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.