Skip to content

Commit

Permalink
(GH-3587) Add resource dict Controls.AnimatedSingleRowTabControl.xaml…
Browse files Browse the repository at this point in the history
… and style MahApps.Styles.TabControl.AnimatedSingleRow
  • Loading branch information
punker76 committed May 16, 2020
1 parent 9d7b02e commit 1df4618
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@
Style="{DynamicResource DescriptionHeaderStyle}" />
<ContentControl DataContext="{Binding ElementName=AnimatedSingleRowTabControl}" Template="{StaticResource TabControlConfigDataTemplate}" />
<Grid>
<Grid.Resources>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
</Grid.Resources>
<TabControl x:Name="AnimatedSingleRowTabControl" Height="150">
<TabControl x:Name="AnimatedSingleRowTabControl" Height="150" Style="{DynamicResource MahApps.Styles.TabControl.AnimatedSingleRow}">
<TabItem Header="these tabs">
<TextBlock FontSize="30" Text="first content" />
</TabItem>
Expand Down
41 changes: 21 additions & 20 deletions src/MahApps.Metro/Styles/Controls.AnimatedSingleRowTabControl.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Behaviors="clr-namespace:MahApps.Metro.Behaviors"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls">
xmlns:behaviors="clr-namespace:MahApps.Metro.Behaviors"
xmlns:mah="clr-namespace:MahApps.Metro.Controls">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TabControl.xaml" />
Expand Down Expand Up @@ -160,14 +160,14 @@
<ScrollViewer x:Name="HeaderPanelScroll"
Grid.Row="0"
Panel.ZIndex="1"
Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled="{TemplateBinding Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled}"
mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled="{TemplateBinding mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled}"
HorizontalScrollBarVisibility="Auto"
Template="{StaticResource MahApps.Templates.ScrollViewer.AnimatedSingleRow}"
VerticalScrollBarVisibility="Disabled">
<Grid x:Name="HeaderPanelGrid">
<Controls:Underline x:Name="Underline"
<mah:Underline x:Name="Underline"
Background="Transparent"
BorderBrush="{TemplateBinding Controls:TabControlHelper.UnderlineBrush}"
BorderBrush="{TemplateBinding mah:TabControlHelper.UnderlineBrush}"
LineThickness="1"
Placement="Bottom"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Expand All @@ -177,21 +177,21 @@
KeyboardNavigation.TabIndex="1" />
</Grid>
</ScrollViewer>
<Controls:TransitioningContentControl x:Name="ContentPanel"
<mah:TransitioningContentControl x:Name="ContentPanel"
Grid.Row="1"
Behaviors:ReloadBehavior.OnSelectedTabChanged="True"
behaviors:ReloadBehavior.OnSelectedTabChanged="True"
RestartTransitionOnContentChange="True"
Transition="{TemplateBinding Controls:TabControlHelper.Transition}"
Transition="{TemplateBinding mah:TabControlHelper.Transition}"
UseLayoutRounding="True">
<ContentPresenter x:Name="PART_SelectedContentHost"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False" />
</Controls:TransitioningContentControl>
</mah:TransitioningContentControl>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Controls:TabControlHelper.Underlined" Value="TabPanel">
<Trigger Property="mah:TabControlHelper.Underlined" Value="TabPanel">
<Setter TargetName="Underline" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Top">
Expand Down Expand Up @@ -226,9 +226,9 @@
Template="{StaticResource MahApps.Templates.ScrollViewer.AnimatedSingleRow}"
VerticalScrollBarVisibility="Auto">
<Grid x:Name="HeaderPanelGrid">
<Controls:Underline x:Name="Underline"
<mah:Underline x:Name="Underline"
Background="Transparent"
BorderBrush="{TemplateBinding Controls:TabControlHelper.UnderlineBrush}"
BorderBrush="{TemplateBinding mah:TabControlHelper.UnderlineBrush}"
LineThickness="1"
Placement="Bottom"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Expand All @@ -238,21 +238,21 @@
KeyboardNavigation.TabIndex="1" />
</Grid>
</ScrollViewer>
<Controls:TransitioningContentControl x:Name="ContentPanel"
<mah:TransitioningContentControl x:Name="ContentPanel"
Grid.Column="0"
Behaviors:ReloadBehavior.OnSelectedTabChanged="True"
behaviors:ReloadBehavior.OnSelectedTabChanged="True"
RestartTransitionOnContentChange="True"
Transition="{TemplateBinding Controls:TabControlHelper.Transition}"
Transition="{TemplateBinding mah:TabControlHelper.Transition}"
UseLayoutRounding="True">
<ContentPresenter x:Name="PART_SelectedContentHost"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False" />
</Controls:TransitioningContentControl>
</mah:TransitioningContentControl>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Controls:TabControlHelper.Underlined" Value="TabPanel">
<Trigger Property="mah:TabControlHelper.Underlined" Value="TabPanel">
<Setter TargetName="Underline" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
Expand All @@ -274,9 +274,9 @@
</ControlTemplate.Triggers>
</ControlTemplate>

<Style BasedOn="{StaticResource MahApps.Styles.TabControl}" TargetType="{x:Type TabControl}">
<Setter Property="Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled" Value="True" />
<Setter Property="Controls:TabControlHelper.Transition" Value="Left" />
<Style x:Key="MahApps.Styles.TabControl.AnimatedSingleRow" BasedOn="{StaticResource MahApps.Styles.TabControl}" TargetType="{x:Type TabControl}">
<Setter Property="mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled" Value="True" />
<Setter Property="mah:TabControlHelper.Transition" Value="Left" />
<Setter Property="Template" Value="{StaticResource MahApps.Templates.TabControl.AnimatedSingleRow.Horizontal}" />
<Style.Triggers>
<Trigger Property="TabStripPlacement" Value="Top">
Expand All @@ -294,4 +294,5 @@

</Style.Triggers>
</Style>

</ResourceDictionary>
1 change: 1 addition & 0 deletions src/MahApps.Metro/Styles/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Slider.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatSlider.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBlock.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Label.xaml" />
Expand Down
50 changes: 23 additions & 27 deletions src/MahApps.Metro/Themes/MetroAnimatedSingleRowTabControl.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Behaviors="clr-namespace:MahApps.Metro.Behaviors"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls">
xmlns:behaviors="clr-namespace:MahApps.Metro.Behaviors"
xmlns:mah="clr-namespace:MahApps.Metro.Controls">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
<!-- MahApps.Styles.ScrollViewer -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TabControl.xaml" />
</ResourceDictionary.MergedDictionaries>

<ControlTemplate x:Key="MahApps.Templates.MetroAnimatedSingleRowTabControl.Horizontal" TargetType="{x:Type Controls:MetroAnimatedSingleRowTabControl}">
<ControlTemplate x:Key="MahApps.Templates.MetroAnimatedSingleRowTabControl.Horizontal" TargetType="{x:Type mah:MetroAnimatedSingleRowTabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto" />
Expand All @@ -19,14 +17,13 @@
Grid.Row="0"
Margin="{TemplateBinding TabStripMargin}"
Panel.ZIndex="1"
Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled="{TemplateBinding Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled}"
mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled="{TemplateBinding mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled}"
HorizontalScrollBarVisibility="Auto"
Style="{DynamicResource MahApps.Styles.ScrollViewer}"
VerticalScrollBarVisibility="Disabled">
<Grid x:Name="HeaderPanelGrid">
<Controls:Underline x:Name="Underline"
<mah:Underline x:Name="Underline"
Background="Transparent"
BorderBrush="{TemplateBinding Controls:TabControlHelper.UnderlineBrush}"
BorderBrush="{TemplateBinding mah:TabControlHelper.UnderlineBrush}"
LineThickness="1"
Placement="Bottom"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Expand All @@ -36,21 +33,21 @@
KeyboardNavigation.TabIndex="1" />
</Grid>
</ScrollViewer>
<Controls:TransitioningContentControl x:Name="ContentPanel"
<mah:TransitioningContentControl x:Name="ContentPanel"
Grid.Row="1"
Behaviors:ReloadBehavior.OnSelectedTabChanged="True"
behaviors:ReloadBehavior.OnSelectedTabChanged="True"
RestartTransitionOnContentChange="True"
Transition="{TemplateBinding Controls:TabControlHelper.Transition}"
Transition="{TemplateBinding mah:TabControlHelper.Transition}"
UseLayoutRounding="True">
<ContentPresenter x:Name="PART_SelectedContentHost"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False" />
</Controls:TransitioningContentControl>
</mah:TransitioningContentControl>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Controls:TabControlHelper.Underlined" Value="TabPanel">
<Trigger Property="mah:TabControlHelper.Underlined" Value="TabPanel">
<Setter TargetName="Underline" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Top">
Expand All @@ -70,7 +67,7 @@
</ControlTemplate.Triggers>
</ControlTemplate>

<ControlTemplate x:Key="MahApps.Templates.MetroAnimatedSingleRowTabControl.Vertical" TargetType="{x:Type Controls:MetroAnimatedSingleRowTabControl}">
<ControlTemplate x:Key="MahApps.Templates.MetroAnimatedSingleRowTabControl.Vertical" TargetType="{x:Type mah:MetroAnimatedSingleRowTabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0" Width="*" />
Expand All @@ -81,12 +78,11 @@
Margin="{TemplateBinding TabStripMargin}"
Panel.ZIndex="1"
HorizontalScrollBarVisibility="Disabled"
Style="{DynamicResource MahApps.Styles.ScrollViewer}"
VerticalScrollBarVisibility="Auto">
<Grid x:Name="HeaderPanelGrid">
<Controls:Underline x:Name="Underline"
<mah:Underline x:Name="Underline"
Background="Transparent"
BorderBrush="{TemplateBinding Controls:TabControlHelper.UnderlineBrush}"
BorderBrush="{TemplateBinding mah:TabControlHelper.UnderlineBrush}"
LineThickness="1"
Placement="Bottom"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Expand All @@ -96,21 +92,21 @@
KeyboardNavigation.TabIndex="1" />
</Grid>
</ScrollViewer>
<Controls:TransitioningContentControl x:Name="ContentPanel"
<mah:TransitioningContentControl x:Name="ContentPanel"
Grid.Column="0"
Behaviors:ReloadBehavior.OnSelectedTabChanged="True"
behaviors:ReloadBehavior.OnSelectedTabChanged="True"
RestartTransitionOnContentChange="True"
Transition="{TemplateBinding Controls:TabControlHelper.Transition}"
Transition="{TemplateBinding mah:TabControlHelper.Transition}"
UseLayoutRounding="True">
<ContentPresenter x:Name="PART_SelectedContentHost"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False" />
</Controls:TransitioningContentControl>
</mah:TransitioningContentControl>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Controls:TabControlHelper.Underlined" Value="TabPanel">
<Trigger Property="mah:TabControlHelper.Underlined" Value="TabPanel">
<Setter TargetName="Underline" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
Expand All @@ -130,9 +126,9 @@
</ControlTemplate.Triggers>
</ControlTemplate>

<Style BasedOn="{StaticResource MahApps.Styles.TabControl}" TargetType="{x:Type Controls:MetroAnimatedSingleRowTabControl}">
<Setter Property="Controls:ScrollViewerHelper.IsHorizontalScrollWheelEnabled" Value="True" />
<Setter Property="Controls:TabControlHelper.Transition" Value="Left" />
<Style BasedOn="{StaticResource MahApps.Styles.TabControl}" TargetType="{x:Type mah:MetroAnimatedSingleRowTabControl}">
<Setter Property="mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled" Value="True" />
<Setter Property="mah:TabControlHelper.Transition" Value="Left" />
<Setter Property="Template" Value="{StaticResource MahApps.Templates.MetroAnimatedSingleRowTabControl.Horizontal}" />
<Style.Triggers>
<Trigger Property="TabStripPlacement" Value="Top">
Expand Down
12 changes: 4 additions & 8 deletions src/Mahapps.Metro.Tests/Views/AnimatedTabControlWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@
<controls:MetroAnimatedSingleRowTabControl x:Name="MetroTabControl"
ContentTemplateSelector="{StaticResource TabControlContentTemplateSelector}"
ItemsSource="{Binding Data.TestViewModels}" />
<Grid>
<Grid.Resources>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
</Grid.Resources>
<TabControl x:Name="NormalTabControl"
ContentTemplateSelector="{StaticResource TabControlContentTemplateSelector}"
ItemsSource="{Binding Data.TestViewModels}" />
</Grid>
<TabControl x:Name="NormalTabControl"
Style="{DynamicResource MahApps.Styles.TabControl.AnimatedSingleRow}"
ContentTemplateSelector="{StaticResource TabControlContentTemplateSelector}"
ItemsSource="{Binding Data.TestViewModels}" />

<controls:MetroAnimatedTabControl x:Name="MetroTabControl2"
ContentTemplateSelector="{StaticResource TabControlContentTemplateSelector}"
Expand Down

0 comments on commit 1df4618

Please sign in to comment.