Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara authored Dec 2, 2023
1 parent c3b1c36 commit eb688f8
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
4 changes: 3 additions & 1 deletion ModernWpf.Controls/ToggleSwitch/ToggleSwitch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="ui:FocusVisualHelper.FocusVisualMargin" Value="-7,-3,-7,-3" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:ToggleSwitch">
Expand Down Expand Up @@ -351,11 +352,12 @@
<ColumnDefinition Width="12" MaxWidth="12" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid
<Border
x:Name="SwitchAreaGrid"
Grid.RowSpan="3"
Grid.ColumnSpan="3"
Margin="0,5"
CornerRadius="{TemplateBinding CornerRadius}"
ui:FocusVisualHelper.IsTemplateFocusTarget="True"
Background="{DynamicResource ToggleSwitchContainerBackground}" />
<ContentPresenter
Expand Down
4 changes: 3 additions & 1 deletion ModernWpf/Controls/Primitives/FocusVisualHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -486,6 +485,7 @@ private static void OnFocusVisualIsVisibleChanged(object sender, DependencyPrope
TransferValue(focusedElement, focusVisual, FocusVisualPrimaryThicknessProperty);
TransferValue(focusedElement, focusVisual, FocusVisualSecondaryBrushProperty);
TransferValue(focusedElement, focusVisual, FocusVisualSecondaryThicknessProperty);
TransferValue(focusedElement, focusVisual, ControlHelper.CornerRadiusProperty);
focusVisual.Margin = GetFocusVisualMargin(focusedElement);
}

Expand All @@ -502,6 +502,7 @@ private static void OnFocusVisualIsVisibleChanged(object sender, DependencyPrope
focusVisual.ClearValue(FocusVisualPrimaryThicknessProperty);
focusVisual.ClearValue(FocusVisualSecondaryBrushProperty);
focusVisual.ClearValue(FocusVisualSecondaryThicknessProperty);
focusVisual.ClearValue(ControlHelper.CornerRadiusProperty);
focusVisual.ClearValue(FrameworkElement.MarginProperty);
focusVisual.ClearValue(Control.TemplateProperty);
focusVisual.ClearValue(FocusedElementProperty);
Expand Down Expand Up @@ -535,6 +536,7 @@ public FocusVisualAdorner(Control focusedElement, UIElement adornedElement, Styl
TransferValue(focusedElement, control, FocusVisualPrimaryThicknessProperty);
TransferValue(focusedElement, control, FocusVisualSecondaryBrushProperty);
TransferValue(focusedElement, control, FocusVisualSecondaryThicknessProperty);
TransferValue(focusedElement, control, ControlHelper.CornerRadiusProperty);
_adorderChild = control;
IsClipEnabled = true;
IsHitTestVisible = false;
Expand Down
5 changes: 4 additions & 1 deletion ModernWpf/Styles/Calendar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Background" Value="{DynamicResource CalendarViewNavigationButtonBackground}" />
<Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="primitives:FocusVisualHelper.FocusVisualMargin" Value="2,2,2,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
Expand All @@ -57,7 +59,8 @@
Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource CalendarViewNavigationButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="{TemplateBinding Padding}">
Margin="{TemplateBinding Padding}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
<ContentPresenter
x:Name="Text"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand Down
11 changes: 6 additions & 5 deletions ModernWpf/Styles/RadioButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,31 @@
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
<Setter Property="primitives:FocusVisualHelper.FocusVisualMargin" Value="-7,-3,-7,-3" />
<Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<ControlTemplate.Resources>
<primitives:BrushToColorConverter x:Key="BrushToColorConverter" />
</ControlTemplate.Resources>

<Border
x:Name="RootGrid"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
SnapsToDevicePixels="True">
SnapsToDevicePixels="True">

<Border.Resources>
<primitives:BindingProxy x:Key="RadioButtonOuterEllipseFillPointerOverProxy" Value="{DynamicResource RadioButtonOuterEllipseFillPointerOver}" />
<primitives:BindingProxy x:Key="RadioButtonOuterEllipseFillPressedProxy" Value="{DynamicResource RadioButtonOuterEllipseFillPressed}" />
<primitives:BindingProxy x:Key="RadioButtonOuterEllipseFillDisabledProxy" Value="{DynamicResource RadioButtonOuterEllipseFillDisabled}" />
<primitives:BindingProxy x:Key="RadioButtonOuterEllipseCheckedStrokeDisabledProxy" Value="{DynamicResource RadioButtonOuterEllipseCheckedStrokeDisabled}" />
<primitives:BindingProxy x:Key="RadioButtonOuterEllipseCheckedFillDisabledProxy" Value="{DynamicResource RadioButtonOuterEllipseCheckedFillDisabled}" />
</Border.Resources>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
Expand Down Expand Up @@ -134,7 +135,7 @@
<VisualState x:Name="Indeterminate" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
Expand Down
16 changes: 10 additions & 6 deletions ModernWpf/Styles/Slider.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@
TextWrapping="Wrap"
Visibility="{TemplateBinding primitives:ControlHelper.HeaderVisibility}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Grid
<Border
x:Name="SliderContainer"
Grid.Row="1"
Background="{DynamicResource SliderContainerBackground}"
primitives:FocusVisualHelper.IsTemplateFocusTarget="True">
primitives:FocusVisualHelper.IsTemplateFocusTarget="True"
CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid
x:Name="HorizontalTemplate"
MinHeight="{DynamicResource SliderHorizontalHeight}">
Expand Down Expand Up @@ -230,6 +231,7 @@
DataContext="{TemplateBinding Value}"
Height="{DynamicResource SliderHorizontalThumbHeight}"
Width="{DynamicResource SliderHorizontalThumbWidth}"
primitives:ControlHelper.CornerRadius="{DynamicResource ControlCornerRadius}"
primitives:FocusVisualHelper.FocusVisualMargin="-14,-6,-14,-6">
<Thumb.Resources>
<Style TargetType="ToolTip" BasedOn="{StaticResource SliderAutoToolTipStyle}" />
Expand All @@ -238,7 +240,7 @@
</Track.Thumb>
</Track>
</Grid>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
Expand Down Expand Up @@ -296,11 +298,12 @@
Visibility="{TemplateBinding primitives:ControlHelper.HeaderVisibility}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
</local:ContentPresenterEx>
<Grid
<Border
x:Name="SliderContainer"
Grid.Row="1"
Background="{DynamicResource SliderContainerBackground}"
primitives:FocusVisualHelper.IsTemplateFocusTarget="True">
primitives:FocusVisualHelper.IsTemplateFocusTarget="True"
CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid
x:Name="VerticalTemplate"
MinWidth="{DynamicResource SliderVerticalWidth}">
Expand Down Expand Up @@ -376,6 +379,7 @@
DataContext="{TemplateBinding Value}"
Width="{DynamicResource SliderVerticalThumbWidth}"
Height="{DynamicResource SliderVerticalThumbHeight}"
primitives:ControlHelper.CornerRadius="{DynamicResource ControlCornerRadius}"
primitives:FocusVisualHelper.FocusVisualMargin="-6,-14,-6,-14">
<Thumb.Resources>
<Style TargetType="ToolTip" BasedOn="{StaticResource SliderAutoToolTipStyle}" />
Expand All @@ -384,7 +388,7 @@
</Track.Thumb>
</Track>
</Grid>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
Expand Down
4 changes: 3 additions & 1 deletion ModernWpf/ThemeResources/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1768,10 +1768,12 @@
<Border
BorderBrush="{TemplateBinding primitives:FocusVisualHelper.FocusVisualPrimaryBrush}"
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualPrimaryThickness}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
SnapsToDevicePixels="True">
<Border
BorderBrush="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryBrush}"
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryThickness}" />
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryThickness}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
</Border>
</ControlTemplate>
</Setter.Value>
Expand Down
4 changes: 3 additions & 1 deletion ModernWpf/ThemeResources/HighContrast.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1645,10 +1645,12 @@
<Border
BorderBrush="{StaticResource SystemControlFocusVisualPrimaryBrush}"
BorderThickness="2"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
SnapsToDevicePixels="True">
<Border
BorderBrush="{StaticResource SystemControlFocusVisualSecondaryBrush}"
BorderThickness="1" />
BorderThickness="1"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
</Border>
</ControlTemplate>
</Setter.Value>
Expand Down
4 changes: 3 additions & 1 deletion ModernWpf/ThemeResources/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1770,10 +1770,12 @@
<Border
BorderBrush="{TemplateBinding primitives:FocusVisualHelper.FocusVisualPrimaryBrush}"
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualPrimaryThickness}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
SnapsToDevicePixels="True">
<Border
BorderBrush="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryBrush}"
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryThickness}" />
BorderThickness="{TemplateBinding primitives:FocusVisualHelper.FocusVisualSecondaryThickness}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
</Border>
</ControlTemplate>
</Setter.Value>
Expand Down

0 comments on commit eb688f8

Please sign in to comment.