Skip to content

Commit 938e16b

Browse files
committed
scrollviewer
1 parent 97e6ee2 commit 938e16b

File tree

4 files changed

+91
-19
lines changed

4 files changed

+91
-19
lines changed

MaterialDesignColors.WpfExample/ProvingGround.xaml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:system="clr-namespace:System;assembly=mscorlib"
67
x:Class="MaterialDesignColors.WpfExample.ProvingGround"
78
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
89
Background="{DynamicResource MaterialDesignPaper}"
@@ -48,7 +49,8 @@
4849
<SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="{StaticResource Accent700Foreground}"/>
4950
</ResourceDictionary>
5051
</ResourceDictionary.MergedDictionaries>
51-
52+
53+
5254

5355
</ResourceDictionary>
5456

@@ -59,24 +61,30 @@
5961
<ColumnDefinition Width="1*" />
6062
<ColumnDefinition Width="1*" />
6163
</Grid.ColumnDefinitions>
62-
<ScrollBar Orientation="Vertical" Style="{DynamicResource MaterialDesignScrollBar}"
63-
Grid.Column="0"
64-
HorizontalAlignment="Left"
65-
/>
66-
<ScrollBar Orientation="Vertical" Style="{DynamicResource MaterialDesignScrollBar}"
67-
IsEnabled="False"
68-
Grid.Column="0"
69-
HorizontalAlignment="Right"
70-
/>
71-
<ScrollBar Orientation="Horizontal" Style="{DynamicResource MaterialDesignScrollBar}"
72-
Grid.Column="1"
73-
VerticalAlignment="Top"
74-
/>
75-
<ScrollBar Orientation="Horizontal" Style="{DynamicResource MaterialDesignScrollBar}"
76-
IsEnabled="False"
77-
Grid.Column="1"
78-
VerticalAlignment="Bottom"
79-
/>
64+
<ScrollViewer>
65+
<ItemsControl>
66+
<system:String>ghg</system:String>
67+
<system:String>ghg</system:String>
68+
<system:String>ghg</system:String>
69+
<system:String>ghg</system:String>
70+
<system:String>ghg</system:String>
71+
<system:String>ghg</system:String>
72+
<system:String>ghg</system:String>
73+
<system:String>ghg</system:String>
74+
<system:String>ghg</system:String>
75+
<system:String>ghg</system:String>
76+
<system:String>ghg</system:String>
77+
<system:String>ghg</system:String>
78+
<system:String>ghg</system:String>
79+
<system:String>ghg</system:String>
80+
<system:String>ghg</system:String>
81+
<system:String>ghg</system:String>
82+
<system:String>ghg</system:String>
83+
<system:String>ghg</system:String>
84+
<system:String>ghg</system:String>
85+
<system:String>ghg</system:String>
86+
</ItemsControl>
87+
</ScrollViewer>
8088
</Grid>
8189

8290
</UserControl>

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
<SubType>Designer</SubType>
109109
<Generator>MSBuild:Compile</Generator>
110110
</Page>
111+
<Page Include="Themes\MaterialDesignTheme.ScrollViewer.xaml">
112+
<SubType>Designer</SubType>
113+
<Generator>MSBuild:Compile</Generator>
114+
</Page>
111115
<Page Include="Themes\MaterialDesignTheme.Shadows.xaml">
112116
<SubType>Designer</SubType>
113117
<Generator>MSBuild:Compile</Generator>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Defaults.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PasswordBox.xaml" />
1717
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
1818
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollBar.xaml" />
19+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollViewer.xaml" />
1920
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.slider.xaml" />
2021
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.textbox.xaml" />
2122
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.togglebutton.xaml" />
@@ -37,6 +38,7 @@
3738
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignPasswordBox}" />
3839
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource MaterialDesignRadioButton}" />
3940
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource MaterialDesignScrollBar}" />
41+
<Style TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource MaterialDesignScrollViewer}" />
4042
<Style TargetType="{x:Type Slider}" BasedOn="{StaticResource MaterialDesignSlider}" />
4143
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}" />
4244
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<ControlTemplate x:Key="MaterialDesignScrollViewerTemplate" TargetType="{x:Type ScrollViewer}">
4+
<ControlTemplate.Resources>
5+
<Storyboard x:Key="MouseEnter">
6+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_HorizontalScrollBar">
7+
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/>
8+
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
9+
</DoubleAnimationUsingKeyFrames>
10+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_VerticalScrollBar">
11+
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/>
12+
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
13+
</DoubleAnimationUsingKeyFrames>
14+
</Storyboard>
15+
<Storyboard x:Key="MouseExit">
16+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_VerticalScrollBar">
17+
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/>
18+
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.56"/>
19+
</DoubleAnimationUsingKeyFrames>
20+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_HorizontalScrollBar">
21+
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
22+
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.56"/>
23+
</DoubleAnimationUsingKeyFrames>
24+
</Storyboard>
25+
</ControlTemplate.Resources>
26+
<Grid x:Name="Grid" Background="{TemplateBinding Background}" Opacity="0.56">
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="*"/>
29+
<ColumnDefinition Width="Auto"/>
30+
</Grid.ColumnDefinitions>
31+
<Grid.RowDefinitions>
32+
<RowDefinition Height="*"/>
33+
<RowDefinition Height="Auto"/>
34+
</Grid.RowDefinitions>
35+
<Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource MaterialDesignSelection}" Grid.Row="1"/>
36+
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
37+
<ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"
38+
Opacity=".56" />
39+
<ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"
40+
Opacity=".56" />
41+
</Grid>
42+
<ControlTemplate.Triggers>
43+
<Trigger Property="IsMouseOver" Value="True">
44+
<Trigger.ExitActions>
45+
<BeginStoryboard x:Name="MouseExit_BeginStoryboard" Storyboard="{StaticResource MouseExit}"/>
46+
</Trigger.ExitActions>
47+
<Trigger.EnterActions>
48+
<BeginStoryboard x:Name="MouseEnter_BeginStoryboard" Storyboard="{StaticResource MouseEnter}"/>
49+
</Trigger.EnterActions>
50+
</Trigger>
51+
</ControlTemplate.Triggers>
52+
</ControlTemplate>
53+
54+
<Style TargetType="ScrollViewer" x:Key="MaterialDesignScrollViewer">
55+
<Setter Property="Template" Value="{StaticResource MaterialDesignScrollViewerTemplate}" />
56+
</Style>
57+
58+
</ResourceDictionary>

0 commit comments

Comments
 (0)