-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Applying Win11 Styles to TabControl, Frame, Page #8579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
harshit7962
merged 1 commit into
dotnet:feature/win11theming/staging
from
harshit7962:controlBatch2
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Frame.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- | ||
This Source Code Form is subject to the terms of the MIT License. | ||
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
All Rights Reserved. | ||
--> | ||
|
||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style TargetType="{x:Type Frame}"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="NavigationUIVisibility" Value="Hidden" /> | ||
<Setter Property="Padding" Value="0" /> | ||
<Setter Property="Margin" Value="0" /> | ||
<Setter Property="Focusable" Value="False" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
</Style> | ||
|
||
</ResourceDictionary> |
39 changes: 39 additions & 0 deletions
39
src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Page.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
This Source Code Form is subject to the terms of the MIT License. | ||
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
All Rights Reserved. | ||
--> | ||
|
||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style x:Key="DefaultPageStyle" TargetType="{x:Type Page}"> | ||
<Setter Property="Control.Foreground"> | ||
<Setter.Value> | ||
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<!-- The Display option casues a large aliasing effect --> | ||
<!-- <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" /> --> | ||
<Setter Property="Focusable" Value="False" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Page}"> | ||
<Grid> | ||
<ContentPresenter | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Content="{TemplateBinding ContentControl.Content}" | ||
TextElement.Foreground="{TemplateBinding Control.Foreground}" /> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style BasedOn="{StaticResource DefaultPageStyle}" TargetType="{x:Type Page}" /> | ||
|
||
</ResourceDictionary> |
131 changes: 131 additions & 0 deletions
131
src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TabControl.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<!-- | ||
This Source Code Form is subject to the terms of the MIT License. | ||
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
All Rights Reserved. | ||
--> | ||
|
||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style TargetType="{x:Type TabControl}"> | ||
<Setter Property="Foreground" Value="{DynamicResource TabViewForeground}" /> | ||
<Setter Property="Background" Value="{DynamicResource TabViewBackground}" /> | ||
<Setter Property="BorderBrush" Value="{DynamicResource TabViewBorderBrush}" /> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type TabControl}"> | ||
<Grid KeyboardNavigation.TabNavigation="Local"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<TabPanel | ||
x:Name="HeaderPanel" | ||
Grid.Row="0" | ||
Margin="0" | ||
Panel.ZIndex="1" | ||
Background="Transparent" | ||
IsItemsHost="True" | ||
KeyboardNavigation.TabIndex="1" /> | ||
<Border | ||
x:Name="Border" | ||
Grid.Row="1" | ||
Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="0,1,0,0" | ||
CornerRadius="0,4,4,4" | ||
KeyboardNavigation.DirectionalNavigation="Contained" | ||
KeyboardNavigation.TabIndex="2" | ||
KeyboardNavigation.TabNavigation="Local"> | ||
<ContentPresenter | ||
x:Name="PART_SelectedContentHost" | ||
Margin="0" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
ContentSource="SelectedContent" | ||
TextElement.Foreground="{TemplateBinding Foreground}" /> | ||
</Border> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Disabled" /> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style TargetType="{x:Type TabItem}"> | ||
<Setter Property="Background" Value="{DynamicResource TabViewItemHeaderBackground}" /> | ||
<Setter Property="BorderBrush" Value="Transparent" /> | ||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | ||
<Setter Property="VerticalAlignment" Value="Stretch" /> | ||
<Setter Property="VerticalContentAlignment" Value="Stretch" /> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | ||
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" /> | ||
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" /> | ||
<Setter Property="Focusable" Value="True" /> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type TabItem}"> | ||
<Grid x:Name="Root"> | ||
<Border | ||
x:Name="Border" | ||
MinWidth="180" | ||
MinHeight="36" | ||
Margin="0" | ||
Padding="6" | ||
Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="1,1,1,0" | ||
CornerRadius="8,8,0,0"> | ||
<ContentPresenter | ||
x:Name="ContentSite" | ||
Margin="0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
ContentSource="Header" | ||
RecognizesAccessKey="True" /> | ||
</Border> | ||
|
||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="SelectionStates"> | ||
<VisualState x:Name="Unselected" /> | ||
<VisualState x:Name="Selected" /> | ||
|
||
</VisualStateGroup> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal" /> | ||
<VisualState x:Name="MouseOver" /> | ||
<VisualState x:Name="Disabled"> | ||
<Storyboard> | ||
<DoubleAnimation | ||
Storyboard.TargetName="Border" | ||
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)" | ||
From="0.0" | ||
To="0.5" | ||
Duration="0:0:.16" /> | ||
</Storyboard> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
</Grid> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsSelected" Value="True"> | ||
<Setter Property="Panel.ZIndex" Value="100" /> | ||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource TabViewItemHeaderBackgroundSelected}" /> | ||
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource TabViewSelectedItemBorderBrush}" /> | ||
<Setter Property="Foreground" Value="{DynamicResource TabViewItemForegroundSelected}" /> | ||
</Trigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.