Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody,

unfortunately I'm forced to manipulate code that others created years ago. The solution is a WPF Application (with Caliburn.Micro and Ninject).
Within the shown DevExpress DockLayoutManager is a TabControl created and tabs added dynamically. So no tab appears in XAML.

The only thing I want to do is to influence the Height of the tab header.
I have really tried everything I could imagine or find, including all forums' hints. But nowhere I could access a header or even a single tab, not in XAML and not in code behind. There doesn't seem to be any tab or header iteration. What you must know: Unfortunately the items in the ItemSource are no TabItems, but custom objects. So the also don't have a header...

Any ideas??? The nicest solution would be setting the
XML
<UserControl x:Class="Jenoptik.TS.TDSKpro.Studio.Common.Views.Details.DetailsView"
             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:viewModels="clr-namespace:Jenoptik.TS.TDSKpro.Studio.Common.ViewModels.Details"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
             xmlns:details="clr-namespace:Jenoptik.TS.TDSKpro.Studio.Common.Views.Details"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance viewModels:DetailsViewModel}"
             Grid.IsSharedSizeScope="True">
    <UserControl.Resources>
        <Style TargetType="{x:Type Grid}">
            <Setter Property="VerticalAlignment" Value="Top" />
        </Style>
        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Margin" Value="5,2" />
            <Setter Property="IsReadOnly" Value="True" />
        </Style>
        <Style x:Key="ComboBoxBaseStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
            <Setter Property="Margin" Value="5,2" />
            <Setter Property="MaxWidth" Value="175" />
        </Style>
        <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ComboBoxBaseStyle}" />
        <Style x:Key="LabelBaseStyle" TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
            <Setter Property="Margin" Value="5,2" />
        </Style>
        <Style TargetType="{x:Type Label}" BasedOn="{StaticResource LabelBaseStyle}"/>
        <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
            <Setter Property="Margin" Value="5" />
        </Style>
        <Style x:Key ="ViolationGradingStyleComboBox" TargetType="ComboBox" BasedOn="{StaticResource ComboBoxBaseStyle}">
            <Setter Property="Visibility" Value="{Binding LookupItemsConfiguration.SupportsViolationGradings, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Style.Triggers>
                <DataTrigger  Binding="{Binding ViolationGradings.Count}" Value="0">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key ="ViolationGradingStyleLabel" TargetType="Label" BasedOn="{StaticResource LabelBaseStyle}">
            <Setter Property="Visibility" Value="{Binding LookupItemsConfiguration.SupportsViolationGradings, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <Style.Triggers>
                <DataTrigger  Binding="{Binding ViolationGradings.Count}" Value="0">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <dxdo:DockLayoutManager
        ItemsSource="{Binding Items}"
        Height="235"
        ManualClosedPanelsBarVisibility="False"
        ShowInvisibleItemsInCustomizationForm="False"
        ShowInvisibleItems="False"
        ClosedPanelsBarPosition="Bottom"
        ClosedPanelsBarVisibility="Never"
        x:Name="DockLayoutManager">
        <dxdo:MVVMHelper.LayoutAdapter>
            <details:LayoutAdapter/>
        </dxdo:MVVMHelper.LayoutAdapter>
        <dxdo:DockLayoutManager.Resources>
            <Style TargetType="{x:Type dxdo:DocumentPanel}">
Value="10"></Setter>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="CustomizationCaption" Value="{Binding Caption}"/>
                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Border Margin="5" Padding="5" >
                                <Border.Background>
                                    <SolidColorBrush Color="{DynamicResource Color_05_pantone_gray_20}" />
                                </Border.Background>
                                <ScrollViewer Name="ScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                    <ContentControl cal:View.Model="{Binding}"/>
                                </ScrollViewer>
                            </Border>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="CaptionTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                                <Image Height="16" Margin="5,0,0,0" Source="{Binding CaptionImagePath}"/>
                                <Label Content="{Binding Caption}" />
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="BindableName" Value="{Binding Identifier}" />
                <Style.Triggers>
                    <DataTrigger  Binding="{Binding IsVisible}" Value="false">
                        <Setter Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </dxdo:DockLayoutManager.Resources>
        <dxdo:DockLayoutManager.LayoutRoot>
            <dxdo:LayoutGroup Name="LayoutGroup">
                <dxdo:DocumentGroup Name="DetailsGroup" />
            </dxdo:LayoutGroup>
        </dxdo:DockLayoutManager.LayoutRoot>
    </dxdo:DockLayoutManager>
</UserControl>

The same problem exists for this simpler view:
XML
<UserControl x:Class="Jenoptik.TS.TDSKpro.Studio.Common.Views.DocumentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d">

    <TabControl x:Name="SegmentTabs"
                Foreground="Transparent"
                ItemsSource="{Binding Items}"
                SelectedItem="{Binding ActiveItem}">
        <tabcontrol.background>
            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Offset="1" Color="#FFDEDFE0" />
                <GradientStop Color="White" />
            
        
        <tabcontrol.itemtemplate>
            <datatemplate>
                <TextBlock Text="{Binding DisplayName}" />
            
        
        <tabcontrol.contenttemplate>
            <datatemplate>
                <ContentControl HorizontalContentAlignment="Stretch"
                                VerticalContentAlignment="Stretch"
                                cal:View.Model="{Binding}" />


What I have tried:

setting Height everywhere in XAML
accessing the tab control and it's tabs and headers
Posted
Updated 27-Sep-17 3:45am
v2

1 solution

Hi oistrez,

You are using an "ItemTemplate" (btw why ist the XAML not correct in you example = lowercase itemtemplate...)
So this is what controls the "inside" of you TabPage header.

You use just a TextBlock here - so you could set it's Height just by Controlling the DataTemplate
like this

TabControl.ItemTemplate>
<DataTemplate>
 <TextBlock Text="{Binding DisplayName}" Height="50">
...


Another way would be to directly manipulate the ControlTemplate that is behind an TabItem (I hope you know how to generate them in VS -if you don't see them in your Code base?)
So as example the one I get for the default (Windows-Theme) TabItem
      <Style x:Key="TabItemStyle1" TargetType="{x:Type TabItem}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
            <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="6,2,6,2"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
                            <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0">
                                <Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,1,0" Background="{StaticResource TabItem.Selected.Background}" Margin="-1" Opacity="0"/>
                            </Border>
                            <ContentPresenter x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                        </Grid>
...


You see the ContentPresenter which is responsable for showing the Header - you could replace this with anything you want...

I hope this helps,

Kind regards

Johannes
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900