forked from chocolatey/ChocolateyGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolateyGH-685) Add better ScrollBar and ScrollViewer styles
- Loading branch information
Showing
5 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
115 changes: 115 additions & 0 deletions
115
Source/ChocolateyGui.Common.Windows/Resources/ControlStyles/ScrollBar.xaml
This file contains 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,115 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib" | ||
xmlns:theming="clr-namespace:ChocolateyGui.Common.Windows.Theming"> | ||
|
||
<Thickness x:Key="ThumbBorderThickness">0</Thickness> | ||
<CornerRadius x:Key="ThumbCornerRadius">2</CornerRadius> | ||
<system:Double x:Key="ThumbSize">8</system:Double> | ||
|
||
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}"> | ||
<Setter Property="Focusable" Value="False" /> | ||
<Setter Property="IsTabStop" Value="False" /> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type RepeatButton}"> | ||
<Border Background="Transparent" /> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"> | ||
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray8}" /> | ||
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.Gray8}" /> | ||
<Setter Property="BorderThickness" Value="{StaticResource ThumbBorderThickness}" /> | ||
<Setter Property="Margin" Value="1" /> | ||
<Setter Property="Focusable" Value="False" /> | ||
<Setter Property="IsTabStop" Value="False" /> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Thumb}"> | ||
<Border Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="{TemplateBinding BorderThickness}" | ||
CornerRadius="{StaticResource ThumbCornerRadius}" /> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray9}" /> | ||
</Trigger> | ||
<DataTrigger Binding="{Binding Source={x:Static theming:BundledTheme.DefaultInstance}, Path=IsLightTheme}" Value="True"> | ||
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray5}" /> | ||
</DataTrigger> | ||
<MultiDataTrigger> | ||
<MultiDataTrigger.Conditions> | ||
<Condition Binding="{Binding Source={x:Static theming:BundledTheme.DefaultInstance}, Path=IsLightTheme}" Value="True" /> | ||
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" /> | ||
</MultiDataTrigger.Conditions> | ||
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray2}" /> | ||
</MultiDataTrigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Track Name="PART_Track" IsDirectionReversed="True"> | ||
<Track.DecreaseRepeatButton> | ||
<RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}" /> | ||
</Track.DecreaseRepeatButton> | ||
<Track.Thumb> | ||
<Thumb Style="{StaticResource ScrollBarThumb}" /> | ||
</Track.Thumb> | ||
<Track.IncreaseRepeatButton> | ||
<RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}" /> | ||
</Track.IncreaseRepeatButton> | ||
</Track> | ||
</Grid> | ||
</ControlTemplate> | ||
|
||
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Track Name="PART_Track" IsDirectionReversed="False"> | ||
<Track.DecreaseRepeatButton> | ||
<RepeatButton Command="ScrollBar.PageLeftCommand" Style="{StaticResource ScrollBarPageButton}" /> | ||
</Track.DecreaseRepeatButton> | ||
<Track.Thumb> | ||
<Thumb Style="{StaticResource ScrollBarThumb}" /> | ||
</Track.Thumb> | ||
<Track.IncreaseRepeatButton> | ||
<RepeatButton Command="ScrollBar.PageRightCommand" Style="{StaticResource ScrollBarPageButton}" /> | ||
</Track.IncreaseRepeatButton> | ||
</Track> | ||
</Grid> | ||
</ControlTemplate> | ||
|
||
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}"> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="SnapsToDevicePixels" Value="True" /> | ||
<Style.Triggers> | ||
<Trigger Property="Orientation" Value="Horizontal"> | ||
<Setter Property="Height" Value="{StaticResource ThumbSize}" /> | ||
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" /> | ||
<Setter Property="Width" Value="Auto" /> | ||
</Trigger> | ||
<Trigger Property="Orientation" Value="Vertical"> | ||
<Setter Property="Height" Value="Auto" /> | ||
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" /> | ||
<Setter Property="Width" Value="{StaticResource ThumbSize}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
</ResourceDictionary> |
48 changes: 48 additions & 0 deletions
48
Source/ChocolateyGui.Common.Windows/Resources/ControlStyles/ScrollViewer.xaml
This file contains 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,48 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style x:Key="{x:Type ScrollViewer}" TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource {x:Type ScrollViewer}}"> | ||
<Setter Property="OverridesDefaultStyle" Value="True" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type ScrollViewer}"> | ||
<Grid x:Name="Grid" Background="{TemplateBinding Background}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<ScrollContentPresenter Grid.RowSpan="2" | ||
Grid.ColumnSpan="2" | ||
CanContentScroll="{TemplateBinding CanContentScroll}" | ||
CanHorizontallyScroll="False" | ||
CanVerticallyScroll="False" /> | ||
<ScrollBar Name="PART_VerticalScrollBar" | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
Cursor="Arrow" | ||
Maximum="{TemplateBinding ScrollableHeight}" | ||
Minimum="0" | ||
ViewportSize="{TemplateBinding ViewportHeight}" | ||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" | ||
Value="{TemplateBinding VerticalOffset}" /> | ||
<ScrollBar Name="PART_HorizontalScrollBar" | ||
Grid.Row="1" | ||
Grid.Column="0" | ||
Cursor="Arrow" | ||
Maximum="{TemplateBinding ScrollableWidth}" | ||
Minimum="0" | ||
Orientation="Horizontal" | ||
ViewportSize="{TemplateBinding ViewportWidth}" | ||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" | ||
Value="{TemplateBinding HorizontalOffset}" /> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> |
This file contains 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
This file contains 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