Skip to content

Commit e0755d2

Browse files
authored
Merge pull request #1 from Niranjan16-Ninja/master
To change the tab panel position of TabControlExt to center is resolved.
2 parents ebf2f3a + ae46863 commit e0755d2

14 files changed

+685
-1
lines changed

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
# How-to-change-the-tab-panel-position-of-TabControlExt-to-center-
1+
# How to change the tab panel position of TabControlExt to center
2+
3+
In TabControlExt the tab panel position can be changed using style. In the below sample and code snippet the position of tab panel is changed by changing the HorizontalAlignment property value of TabPanelAdv to Center using style.
4+
5+
## MainWindow.xaml:
6+
7+
<Window x:Class="TabControlAlignment.MainWindow"
8+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
9+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
10+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
11+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
12+
xmlns:local="clr-namespace:TabControlAlignment"
13+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
14+
WindowStartupLocation="CenterScreen"
15+
mc:Ignorable="d"
16+
Title="MainWindow" Height="450" Width="800">
17+
<Window.Resources>
18+
<Style x:Key="NewtabControlExtStyle" TargetType="syncfusion:TabControlExt">
19+
<Setter Property="BorderThickness" Value="1"/>
20+
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
21+
<Style.Triggers>
22+
<MultiDataTrigger>
23+
<Setter Property="Template">
24+
<Setter.Value>
25+
<ControlTemplate TargetType="{x:Type syncfusion:TabControlExt}">
26+
<Grid x:Name="TabControlGrid" Background="{TemplateBinding Background}"
27+
ClipToBounds="False" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition x:Name="ColumnDefinition0"/>
30+
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
31+
</Grid.ColumnDefinitions>
32+
<Grid.RowDefinitions>
33+
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
34+
<RowDefinition x:Name="RowDefinition1" Height="*"/>
35+
</Grid.RowDefinitions>
36+
<syncfusion:HeaderPanel x:Name="HeaderPanel" Background="{TemplateBinding TabPanelBackground}"
37+
Grid.Column="0" Focusable="False" HorizontalAlignment="Stretch" Grid.Row="0"
38+
VerticalAlignment="Stretch" Panel.ZIndex="1">
39+
<syncfusion:TabPanelAdv x:Name="PART_TabPanel" DockPanel.Dock="Right" Focusable="False"
40+
HorizontalAlignment="Center" Style="{TemplateBinding TabPanelStyle}"
41+
VerticalAlignment="Stretch">
42+
<syncfusion:TabScrollViewer x:Name="PART_ScrollViewer" Focusable="False"
43+
HorizontalScrollBarVisibility="Hidden" Margin="{Binding Margin,
44+
RelativeSource={RelativeSource FindAncestor, AncestorLevel=1,
45+
AncestorType={x:Type ContentPresenter}}}" PanningMode="HorizontalFirst"
46+
VerticalScrollBarVisibility="Hidden">
47+
<syncfusion:TabLayoutPanel x:Name="PART_TabLayoutPanel" AllowDrop="True"
48+
ClipToBounds="True" HorizontalAlignment="Left" IsItemsHost="True" Margin="0,2,2,-1"
49+
KeyboardNavigation.TabIndex="1" VerticalAlignment="Top"/>
50+
</syncfusion:TabScrollViewer>
51+
</syncfusion:TabPanelAdv>
52+
</syncfusion:HeaderPanel>
53+
<syncfusion:Border3D x:Name="ContentPanel" AllowDrop="True"
54+
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
55+
Grid.Column="0" CornerRadius="2"
56+
KeyboardNavigation.DirectionalNavigation="Contained" Margin="0,1,0,0"
57+
Grid.Row="1" KeyboardNavigation.TabIndex="2"
58+
KeyboardNavigation.TabNavigation="Local">
59+
<Border x:Name="PART_ContentPanelBorder" BorderBrush="#FF69A1BF" BorderThickness="0"
60+
CornerRadius="2">
61+
<Border x:Name="PART_ContentPanelInnerBorder"
62+
BorderBrush="{TemplateBinding BorderBrush}"
63+
BorderThickness="{TemplateBinding BorderThickness}"
64+
Background="{TemplateBinding Background}" CornerRadius="2" Margin="3">
65+
<ContentPresenter x:Name="PART_SelectedContentHost" AllowDrop="True"
66+
ContentTemplate="{TemplateBinding SelectedContentTemplate}"
67+
Content="{TemplateBinding SelectedContent}"
68+
ContentSource="SelectedContent" Margin="{TemplateBinding Padding}"
69+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
70+
</Border>
71+
</Border>
72+
</syncfusion:Border3D>
73+
</Grid>
74+
</ControlTemplate>
75+
</Setter.Value>
76+
</Setter>
77+
</MultiDataTrigger>
78+
</Style.Triggers>
79+
</Style>
80+
</Window.Resources>
81+
82+
<Grid>
83+
<syncfusion:TabControlExt Grid.Column="0" x:Name="MyTabCtrl"
84+
syncfusion:SkinStorage.VisualStyle="Metro"
85+
AllowDragDrop="False"
86+
EnableLabelEdit="False"
87+
TabScrollStyle="Normal"
88+
ShowTabItemContextMenu="False"
89+
CloseButtonType="Hide"
90+
TabStripPlacement="Top"
91+
HorizontalAlignment="Center"
92+
ShowTabListContextMenu="False"
93+
TabItemSelectedBackground="Red"
94+
TabItemHoverBackground ="ForestGreen"
95+
TabItemHoverForeground ="Black"
96+
TabItemHoverBorderBrush="DarkGreen"
97+
TabItemSelectedBorderBrush="Black"
98+
TabItemSelectedForeground="Yellow"
99+
BorderThickness="0" Width="750" Style="{DynamicResource NewtabControlExtStyle}">
100+
<syncfusion:TabControlExt.Resources>
101+
<Style TargetType="{x:Type syncfusion:HeaderPanel}">
102+
<Setter Property="HorizontalAlignment" Value="Center" />
103+
</Style>
104+
</syncfusion:TabControlExt.Resources>
105+
106+
<syncfusion:TabItemExt Header="Properties" Margin="0" HorizontalAlignment="Center">
107+
<TextBlock Text="Properties tab Description" />
108+
</syncfusion:TabItemExt>
109+
<syncfusion:TabItemExt Header="Solution" Margin="0" HorizontalAlignment="Center">
110+
<TextBlock Text="Solution tab Description" />
111+
</syncfusion:TabItemExt>
112+
<syncfusion:TabItemExt Header="Output" Margin="0" HorizontalAlignment="Center">
113+
<TextBlock Text="Output tab Description" />
114+
</syncfusion:TabItemExt>
115+
116+
</syncfusion:TabControlExt>
117+
</Grid>
118+
</Window>

TabControlAlignment/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
5+
</startup>
6+
</configuration>

TabControlAlignment/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="TabControlAlignment.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:TabControlAlignment"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

TabControlAlignment/App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace TabControlAlignment
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<Window x:Class="TabControlAlignment.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:TabControlAlignment"
7+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
8+
WindowStartupLocation="CenterScreen"
9+
mc:Ignorable="d"
10+
Title="MainWindow" Height="450" Width="800">
11+
<Window.Resources>
12+
<Style x:Key="NewtabControlExtStyle" TargetType="syncfusion:TabControlExt">
13+
<Setter Property="BorderThickness" Value="1"/>
14+
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
15+
<Style.Triggers>
16+
<MultiDataTrigger>
17+
<Setter Property="Template">
18+
<Setter.Value>
19+
<ControlTemplate TargetType="{x:Type syncfusion:TabControlExt}">
20+
<Grid x:Name="TabControlGrid" Background="{TemplateBinding Background}" ClipToBounds="False" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
21+
<Grid.ColumnDefinitions>
22+
<ColumnDefinition x:Name="ColumnDefinition0"/>
23+
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
24+
</Grid.ColumnDefinitions>
25+
<Grid.RowDefinitions>
26+
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
27+
<RowDefinition x:Name="RowDefinition1" Height="*"/>
28+
</Grid.RowDefinitions>
29+
<syncfusion:HeaderPanel x:Name="HeaderPanel" Background="{TemplateBinding TabPanelBackground}" Grid.Column="0" Focusable="False" HorizontalAlignment="Stretch" Grid.Row="0" VerticalAlignment="Stretch" Panel.ZIndex="1">
30+
<syncfusion:TabPanelAdv x:Name="PART_TabPanel" DockPanel.Dock="Right" Focusable="False" HorizontalAlignment="Center" Style="{TemplateBinding TabPanelStyle}" VerticalAlignment="Stretch">
31+
<syncfusion:TabScrollViewer x:Name="PART_ScrollViewer" Focusable="False" HorizontalScrollBarVisibility="Hidden" Margin="{Binding Margin, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ContentPresenter}}}" PanningMode="HorizontalFirst" VerticalScrollBarVisibility="Hidden">
32+
<syncfusion:TabLayoutPanel x:Name="PART_TabLayoutPanel" AllowDrop="True" ClipToBounds="True" HorizontalAlignment="Left" IsItemsHost="True" Margin="0,2,2,-1" KeyboardNavigation.TabIndex="1" VerticalAlignment="Top"/>
33+
</syncfusion:TabScrollViewer>
34+
</syncfusion:TabPanelAdv>
35+
</syncfusion:HeaderPanel>
36+
<syncfusion:Border3D x:Name="ContentPanel" AllowDrop="True" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="0" CornerRadius="2" KeyboardNavigation.DirectionalNavigation="Contained" Margin="0,1,0,0" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
37+
<Border x:Name="PART_ContentPanelBorder" BorderBrush="#FF69A1BF" BorderThickness="0" CornerRadius="2">
38+
<Border x:Name="PART_ContentPanelInnerBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2" Margin="3">
39+
<ContentPresenter x:Name="PART_SelectedContentHost" AllowDrop="True" ContentTemplate="{TemplateBinding SelectedContentTemplate}" Content="{TemplateBinding SelectedContent}" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
40+
</Border>
41+
</Border>
42+
</syncfusion:Border3D>
43+
</Grid>
44+
</ControlTemplate>
45+
</Setter.Value>
46+
</Setter>
47+
</MultiDataTrigger>
48+
</Style.Triggers>
49+
</Style>
50+
</Window.Resources>
51+
52+
<Grid>
53+
<syncfusion:TabControlExt Grid.Column="0" x:Name="MyTabCtrl"
54+
syncfusion:SkinStorage.VisualStyle="Metro"
55+
AllowDragDrop="False"
56+
EnableLabelEdit="False"
57+
TabScrollStyle="Normal"
58+
ShowTabItemContextMenu="False"
59+
CloseButtonType="Hide"
60+
TabStripPlacement="Top"
61+
HorizontalAlignment="Center"
62+
ShowTabListContextMenu="False"
63+
TabItemSelectedBackground="Red"
64+
TabItemHoverBackground ="ForestGreen"
65+
TabItemHoverForeground ="Black"
66+
TabItemHoverBorderBrush="DarkGreen"
67+
TabItemSelectedBorderBrush="Black"
68+
TabItemSelectedForeground="Yellow"
69+
BorderThickness="0" Width="750" Style="{DynamicResource NewtabControlExtStyle}">
70+
<syncfusion:TabControlExt.Resources>
71+
<Style TargetType="{x:Type syncfusion:HeaderPanel}">
72+
<Setter Property="HorizontalAlignment" Value="Center" />
73+
</Style>
74+
</syncfusion:TabControlExt.Resources>
75+
76+
<syncfusion:TabItemExt Header="Properties" Margin="0" HorizontalAlignment="Center">
77+
<TextBlock Text="Properties tab Description" />
78+
</syncfusion:TabItemExt>
79+
<syncfusion:TabItemExt Header="Solution" Margin="0" HorizontalAlignment="Center">
80+
<TextBlock Text="Solution tab Description" />
81+
</syncfusion:TabItemExt>
82+
<syncfusion:TabItemExt Header="Output" Margin="0" HorizontalAlignment="Center">
83+
<TextBlock Text="Output tab Description" />
84+
</syncfusion:TabItemExt>
85+
86+
</syncfusion:TabControlExt>
87+
</Grid>
88+
</Window>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace TabControlAlignment
17+
{
18+
/// <summary>
19+
/// Interaction logic for MainWindow.xaml
20+
/// </summary>
21+
public partial class MainWindow : Window
22+
{
23+
public MainWindow()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("TabControlAlignment")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("TabControlAlignment")]
15+
[assembly: AssemblyCopyright("Copyright © 2020")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly: ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
// You can specify all the values or you can default the Build and Revision Numbers
52+
// by using the '*' as shown below:
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.0")]
55+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)