AdvancedTabControl and IsTabKeyboardSwitchingEnabled

Docking/MDI for WPF Forum

Posted 13 days ago by Kevin Pagnat - ADN
Version: 23.1.3
Avatar

Hello,

I'm trying to use the property 'IsTabKeyboardSwitchingEnabled' of AdvancedTabControl but it is overriding the whole style of AdvancedTabControl.

My tabs actually looks like this :

https://ibb.co/k9L5QnD

My code is like this :

<docking:DockSite x:Uid="DockSite" x:Name="DockSite" Style="{StaticResource TabbedDockSiteStyle}">
        <docking:Workspace x:Uid="docking:Workspace_1">
            <docking:TabbedMdiHost
                x:Uid="docking:TabbedMdiHost_1"
                x:Name="TabbedMdiHost"
                TabStripPlacement="{Binding TabStripPlacement, Mode=TwoWay, Converter={StaticResource DockSideConverter}}"
                HasTabPinButtons="{Binding HasTabPinButtons}"
                EmptyContent="{Binding EmptyContent}"
                >
                <docking:TabbedMdiHost.EmptyContentTemplate>
                    <DataTemplate x:Uid="DataTemplate_1">
                        <adn:View x:Uid="adn:View_1" />
                    </DataTemplate>
                </docking:TabbedMdiHost.EmptyContentTemplate>
                <!-- <docking:TabbedMdiHost.TabControlStyle> -->
                <!--     <Style TargetType="docking:TabbedMdiContainerTabControl"> -->
                <!--         <Setter Property="IsTabKeyboardSwitchingEnabled" Value="False" /> -->
                <!--         <Setter Property="IsTabKeyboardAccessEnabled" Value="False" /> -->
                <!--     </Style> -->
                <!-- </docking:TabbedMdiHost.TabControlStyle> -->
            </docking:TabbedMdiHost>
        </docking:Workspace>
    </docking:DockSite>

If I apply the code commented, the keyboard switching is well disabled but the style goes like this :

https://ibb.co/XLZzDtL

How can I achieve what I want then ?

Thanks for your help.

Best regards,

Kevin

Comments (5)

Posted 13 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kevin,

Does it pull in the correct appearance if you add this to your Style element?

BasedOn="{StaticResource {x:Type docking:TabbedMdiContainerTabControl}}"


Actipro Software Support

Posted 12 days ago by Kevin Pagnat - ADN
Avatar

Hi,

This looks promising but unfortunately doesn't work.

My IDE says that the resource can't be found : 

https://ibb.co/34bhZQ3

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

Hi Kevin,

Odd, adding the attribute I mentioned worked for me in Visual Studio ok.  It should be telling it to base the Style on the default Style for that type.  Really that should be happening anyhow though, even with specifying a BasedOn.

Can you give more detailed information about where and how you defined the alternate Style to get the original look you wanted?


Actipro Software Support

Posted 8 days ago by Kevin Pagnat - ADN
Avatar

Thanks for your help on this.

Here is the full code of the page. I'm using Rider as an IDE.

As you will see, the code is using an external file as resources. So you will find also that file just after.

<Border
    x:Uid="UserControl_1"
    x:Class="PresentationLibrary.Views.Docks.TabbedDockingHostView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
    xmlns:docks="clr-namespace:PresentationLibrary.Views.Docks"
    xmlns:adn="clr-namespace:PresentationLibrary"
    xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="300"
    d:DataContext="{d:DesignInstance docks:TabbedDockingHostVM, IsDesignTimeCreatable=True}"
    adn:MVVM.IsView="True"
    >

    <Border.Resources>
        <ResourceDictionary x:Uid="ResourceDictionary_1">
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary x:Uid="ResourceDictionary_2" Source="DockingHostResources.xaml" />
                <ResourceDictionary>
                    <Style x:Key="TabbedMdiContainerTabControlStyle" TargetType="docking:TabbedMdiContainerTabControl" BasedOn="{StaticResource {x:Static themes:SharedResourceKeys.TabControlStyleKey}}">
                        <d:Style.DataContext>
                            <x:Type x:Uid="x:Type_1" Type="docks:TabbedDockingHostVM" />
                        </d:Style.DataContext>
                        <Setter Property="IsTabKeyboardSwitchingEnabled" Value="{Binding IsTabKeyboardSwitchingEnabled}" />
                        <Setter Property="IsTabKeyboardAccessEnabled" Value="{Binding IsTabKeyboardAccessEnabled}" />
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Border.Resources>

    <docking:DockSite x:Uid="DockSite" x:Name="DockSite" Style="{StaticResource TabbedDockSiteStyle}">
        <docking:Workspace x:Uid="docking:Workspace_1">
            <docking:TabbedMdiHost
                x:Uid="docking:TabbedMdiHost_1"
                x:Name="TabbedMdiHost"
                TabStripPlacement="{Binding TabStripPlacement, Mode=TwoWay, Converter={StaticResource DockSideConverter}}"
                HasTabPinButtons="{Binding HasTabPinButtons}"
                EmptyContent="{Binding EmptyContent}"
                TabControlStyle="{StaticResource TabbedMdiContainerTabControlStyle}"
                >
                <docking:TabbedMdiHost.EmptyContentTemplate>
                    <DataTemplate x:Uid="DataTemplate_1">
                        <adn:View x:Uid="adn:View_1" />
                    </DataTemplate>
                </docking:TabbedMdiHost.EmptyContentTemplate>
            </docking:TabbedMdiHost>
        </docking:Workspace>
    </docking:DockSite>
</Border>
<ResourceDictionary
  x:Uid="UserControl_1" x:Class="PresentationLibrary.Views.Docks.DockingHostResources"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
  xmlns:internals1="clr-namespace:PresentationLibrary.Views.Docks.Internals"
  xmlns:docks="clr-namespace:PresentationLibrary.Views.Docks"
  xmlns:presentationLibrary="clr-namespace:PresentationLibrary"
  mc:Ignorable="d"
  >

  <internals1:DockSideConverter x:Uid="internals1:DockSideConverter_1" x:Key="DockSideConverter" />
  
  <Style x:Uid="Style_1" x:Key="DockingWindowStyle" TargetType="docking:DockingWindow">
    <d:Style.DataContext>
      <x:Type x:Uid="x:Type_1" Type="docks:DockingItem" />
    </d:Style.DataContext>

    <!-- On peut normalement utiliser le nom mais cela plante au binding -->
    <Setter x:Uid="Setter_1" Property="SerializationId" Value="{Binding Id, Mode=TwoWay}" />
    <Setter x:Uid="Setter_2" Property="Title" Value="{Binding Path=Title, Mode=TwoWay}" />

    <Setter x:Uid="Setter_3" Property="IsActive" Value="{Binding Path=IsActive, Mode=TwoWay}" />
    <Setter x:Uid="Setter_4" Property="IsOpen" Value="{Binding Path=IsOpen, Mode=TwoWay}" />
    <Setter x:Uid="Setter_5" Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
    <Setter x:Uid="Setter_14" Property="State" Value="{Binding Path=State, Mode=TwoWay}" />
    <Setter x:Uid="Setter_15" Property="IsFloating" Value="{Binding Path=IsFloating, Mode=TwoWay}" />

    <Setter x:Uid="Setter_6" Property="CanClose" Value="{Binding Path=CanClose, Mode=TwoWay}" />
    <Setter x:Uid="Setter_7" Property="CanFloat" Value="{Binding Path=CanFloat, Mode=TwoWay}" />
    <Setter x:Uid="Setter_8" Property="CanDock" Value="{Binding Path=CanDock, Mode=TwoWay}" />
    <Setter x:Uid="Setter_9" Property="CanSerialize" Value="{Binding Path=CanSerialize, Mode=TwoWay}" />
    
    <Setter x:Uid="Setter_11" Property="ContainerDockedSize" Value="{Binding FloatingOrDockedSize, Mode=TwoWay}" />

    <Setter x:Uid="Setter_26" Property="CanAttach" Value="{Binding CanAttach, Mode=TwoWay}" />
    <Setter x:Uid="Setter_27" Property="CanDragTab" Value="{Binding CanDragTab, Mode=TwoWay}" />

    <Setter x:Uid="Setter_29" Property="Padding" Value="{Binding Padding}" />
    <Setter x:Uid="Setter_30" Property="Background" Value="{Binding Background}" />
    
    <Setter x:Uid="Setter_31" Property="TabTintColor" Value="{Binding TabTintColor}" />
    
    <Setter x:Uid="Setter_32" Property="TabbedMdiLayoutKind" Value="{Binding TabbedMdiLayoutKind, Mode=TwoWay}" />

    <!--<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}" />-->

    <!--<Setter Property="Description" Value="{Binding Path=Description, Mode=TwoWay}" />
            <Setter Property="ImageSource" Value="{Binding Path=ImageSource, Mode=TwoWay}" />
            <Setter Property="WindowGroupName" Value="{Binding Path=WindowGroupName, Mode=TwoWay}" />-->
  </Style>

  <Style x:Uid="Style_2" x:Key="ToolWindowStyle" TargetType="docking:ToolWindow"
         BasedOn="{StaticResource DockingWindowStyle}">
    <d:Style.DataContext>
      <x:Type x:Uid="x:Type_2" Type="docks:DockingItem" />
    </d:Style.DataContext>

    <!--<Setter Property="State" Value="{Binding State, Mode=OneWayToSource}" />-->
    <Setter x:Uid="Setter_10" Property="DefaultDockSide" Value="{Binding DefaultDockSide, Mode=TwoWay, Converter={StaticResource DockSideConverter}}" />
    <Setter x:Uid="Setter_12" Property="ContainerAutoHideSize" Value="{Binding ContainerAutoHideSize}" />
    <Setter x:Uid="Setter_13" Property="CanAutoHide" Value="{Binding CanAutoHide}" />
    <Setter x:Uid="Setter_28" Property="HasTitleBar" Value="{Binding HasTitleBar}" />
  </Style>

  <Style x:Uid="Style_3" x:Key="DocumentWindowStyle" TargetType="docking:DocumentWindow"
         BasedOn="{StaticResource DockingWindowStyle}" />

  <DataTemplate x:Uid="DataTemplate_1" x:Key="GenericTemplate" DataType="{x:Type docks:DockingItem}">
    <!-- On décore View d'une bordure pour empêcher MVVM.Render d'être appelé sur le 
                 DockingItem au lieu du DockingContent. -->
    <Border x:Uid="Border_1" DataContext="{Binding DockingContent}">
      <presentationLibrary:View x:Uid="presentationLibrary:View_1" />
    </Border>
  </DataTemplate>

  <Style x:Uid="Style_4" x:Key="DockSiteStyle" TargetType="docking:DockSite">
    <d:Style.DataContext>
      <x:Type x:Uid="x:Type_3" Type="docks:DockingHostVM" />
    </d:Style.DataContext>

    <Setter x:Uid="Setter_16" Property="ToolItemContainerStyle" Value="{StaticResource ToolWindowStyle}" />
    <Setter x:Uid="Setter_17" Property="ToolItemTemplate" Value="{StaticResource GenericTemplate}" />
    <Setter x:Uid="Setter_18" Property="ToolItemsSource" Value="{Binding Tools}" />
    <Setter x:Uid="Setter_19" Property="UseHostedPopups" Value="{Binding UseHostedPopups}" />
    <Setter x:Uid="Setter_20" Property="IsLiveSplittingEnabled" Value="{Binding IsLiveSplittingEnabled}" />
    <Setter x:Uid="Setter_21" Property="AreNewTabsInsertedBeforeExistingTabs" Value="{Binding AreNewTabsInsertedBeforeExistingTabs}" />
  </Style>

  <Style x:Uid="Style_5" x:Key="TabbedDockSiteStyle" TargetType="docking:DockSite" BasedOn="{StaticResource DockSiteStyle}">
    <d:Style.DataContext>
      <x:Type x:Uid="x:Type_4" Type="docks:TabbedDockingHostVM" />
    </d:Style.DataContext>

    <Setter x:Uid="Setter_22" Property="DocumentItemContainerStyle" Value="{StaticResource DocumentWindowStyle}" />
    <Setter x:Uid="Setter_23" Property="DocumentItemTemplate" Value="{StaticResource GenericTemplate}" />
    <Setter x:Uid="Setter_24" Property="DocumentItemsSource" Value="{Binding Documents}" />
  </Style>

  <Style x:Uid="Style_6" x:Key="WorkspaceDockSiteStyle" TargetType="docking:DockSite" BasedOn="{StaticResource DockSiteStyle}">
    <Setter x:Uid="Setter_25" Property="ToolWindowsHaveTitleBars" Value="{Binding ToolWindowsHaveTitleBars}"/>
    <d:Style.DataContext>
      <x:Type x:Uid="x:Type_5" Type="docks:WorkspaceDockingHostVM" />
    </d:Style.DataContext>
  </Style>
</ResourceDictionary>

[Modified 8 days ago]

Answer - Posted 8 days ago by Kevin Pagnat - ADN
Avatar

Ok, nevermind, in fact, it was more complicated than this because I had a parent DockSite that would override eveything.

I just change the property on the parent and eveything goes well !

Thanks for your help.

The latest build of this product (v24.1.2) was released 6 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.