Skip to content

Commit 03f26a4

Browse files
committed
discrete slider style #129
1 parent a832de2 commit 03f26a4

File tree

6 files changed

+179
-88
lines changed

6 files changed

+179
-88
lines changed

MainDemo.Wpf/MainDemo.Wpf.csproj

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@
119119
<Compile Include="ProvingGround.xaml.cs">
120120
<DependentUpon>ProvingGround.xaml</DependentUpon>
121121
</Compile>
122-
<Compile Include="ProvingGroundTemp.xaml.cs">
123-
<DependentUpon>ProvingGroundTemp.xaml</DependentUpon>
124-
</Compile>
125122
<Compile Include="Shadows.xaml.cs">
126123
<DependentUpon>Shadows.xaml</DependentUpon>
127124
</Compile>
125+
<Compile Include="Sliders.xaml.cs">
126+
<DependentUpon>Sliders.xaml</DependentUpon>
127+
</Compile>
128128
<Compile Include="TextFields.xaml.cs">
129129
<DependentUpon>TextFields.xaml</DependentUpon>
130130
</Compile>
@@ -203,11 +203,11 @@
203203
<SubType>Designer</SubType>
204204
<Generator>MSBuild:Compile</Generator>
205205
</Page>
206-
<Page Include="ProvingGroundTemp.xaml">
206+
<Page Include="Shadows.xaml">
207207
<SubType>Designer</SubType>
208208
<Generator>MSBuild:Compile</Generator>
209209
</Page>
210-
<Page Include="Shadows.xaml">
210+
<Page Include="Sliders.xaml">
211211
<SubType>Designer</SubType>
212212
<Generator>MSBuild:Compile</Generator>
213213
</Page>
@@ -281,9 +281,6 @@
281281
<ItemGroup>
282282
<Folder Include="ProvingGroundStuff\" />
283283
</ItemGroup>
284-
<ItemGroup>
285-
<Resource Include="DetministicSliders.jpg" />
286-
</ItemGroup>
287284
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
288285
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
289286
Other similar extension points exist, see Microsoft.Common.targets.

MainDemo.Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
<wpfExample:TextFields />
7171
</domain:DemoItem.Content>
7272
</domain:DemoItem>
73+
<domain:DemoItem Name="Sliders">
74+
<domain:DemoItem.Content>
75+
<wpfExample:Sliders />
76+
</domain:DemoItem.Content>
77+
</domain:DemoItem>
7378
<domain:DemoItem Name="Cards">
7479
<domain:DemoItem.Content>
7580
<wpfExample:Cards />

MainDemo.Wpf/Sliders.xaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<UserControl x:Class="MaterialDesignColors.WpfExample.Sliders"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MaterialDesignColors.WpfExample"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
10+
<UserControl.Resources>
11+
<ResourceDictionary>
12+
<ResourceDictionary.MergedDictionaries>
13+
<!-- note you only need bring in these extra resource dictionaries when using non-default styles, so only bring them into your controls where the default style is not what you want -->
14+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Slider.xaml" />
15+
</ResourceDictionary.MergedDictionaries>
16+
</ResourceDictionary>
17+
</UserControl.Resources>
18+
19+
<Grid VerticalAlignment="Top">
20+
<Grid.ColumnDefinitions>
21+
<ColumnDefinition />
22+
<ColumnDefinition />
23+
</Grid.ColumnDefinitions>
24+
<Grid.RowDefinitions>
25+
<RowDefinition Height="Auto" />
26+
<RowDefinition Height="Auto" />
27+
<RowDefinition Height="Auto" />
28+
<RowDefinition Height="Auto" />
29+
<RowDefinition Height="Auto" />
30+
<RowDefinition Height="Auto" />
31+
</Grid.RowDefinitions>
32+
<Slider Grid.Row="0" TickFrequency="5" Orientation="Horizontal" Minimum="1" Maximum="50" Value="25" />
33+
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" Grid.RowSpan="3"
34+
Margin="0 36 0 0">
35+
<Slider TickFrequency="5" TickPlacement="BottomRight" Orientation="Vertical" Minimum="1" Maximum="50" />
36+
<Slider TickFrequency="25" TickPlacement="TopLeft" Orientation="Vertical" Minimum="1" Maximum="50" IsEnabled="False" Margin="24 8 0 8" />
37+
</StackPanel>
38+
<Slider Grid.Row="1" TickFrequency="5" Orientation="Horizontal" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsSelectionRangeEnabled="True"
39+
Margin="0 36 0 0" />
40+
<Slider Grid.Row="2" TickFrequency="5" Orientation="Horizontal" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsEnabled="False"
41+
Margin="0 36 0 0" />
42+
43+
<StackPanel Orientation="Horizontal" Grid.Row="3" Margin="0 16 0 0">
44+
<TextBlock VerticalAlignment="Bottom">Try me</TextBlock>
45+
<Slider Minimum="0" Maximum="100" Style="{StaticResource MaterialDesignDiscreteSlider}"
46+
Value="50"
47+
Width="280"
48+
Margin="8 0 0 0"/>
49+
</StackPanel>
50+
<Slider Minimum="0" Maximum="10" Margin="0 24 0 0" Style="{StaticResource MaterialDesignDiscreteSlider}" Grid.Row="4" Width="260" HorizontalAlignment="Left" />
51+
<Slider Minimum="0" Maximum="10" Margin="0 24 0 0" Style="{StaticResource MaterialDesignDiscreteSlider}" Grid.Row="5" Width="260" HorizontalAlignment="Left" />
52+
53+
</Grid>
54+
</UserControl>

MainDemo.Wpf/Sliders.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignColors.WpfExample
17+
{
18+
/// <summary>
19+
/// Interaction logic for Sliders.xaml
20+
/// </summary>
21+
public partial class Sliders : UserControl
22+
{
23+
public Sliders()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/TextFields.xaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
<RowDefinition Height="Auto" />
5252
<RowDefinition Height="Auto" />
5353
<RowDefinition Height="Auto" />
54-
<RowDefinition Height="Auto" />
55-
<RowDefinition Height="Auto" />
56-
<RowDefinition Height="Auto" />
5754
</Grid.RowDefinitions>
5855
<Viewbox Grid.Row="0" Grid.Column="0">
5956
<Canvas Width="24" Height="24">
@@ -180,14 +177,6 @@
180177
wpf:TextFieldAssist.Hint="Pick Date"/>
181178
<wpf:TimePicker Grid.Row="5" Grid.Column="3" VerticalAlignment="Top" Width="100" HorizontalAlignment="Left" Margin="0 8 0 8"
182179
wpf:TextFieldAssist.Hint="Custom hint" />
183-
<wpf:TimePicker Grid.Row="5" Grid.Column="4" Is24Hours="True" x:Name="PresetTimePicker" VerticalAlignment="Top" Width="100" HorizontalAlignment="Left" Margin="0 8 0 8" />
184-
<Slider Grid.Row="6" Grid.Column="1" TickFrequency="5" Orientation="Horizontal" Minimum="1" Maximum="50" Value="25" />
185-
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="3" Grid.RowSpan="3" >
186-
<Slider TickFrequency="5" TickPlacement="BottomRight" Orientation="Vertical" Minimum="1" Maximum="50" />
187-
<Slider TickFrequency="25" TickPlacement="TopLeft" Orientation="Vertical" Minimum="1" Maximum="50" IsEnabled="False" Margin="24 8 0 8" />
188-
</StackPanel>
189-
<Slider Grid.Row="7" Grid.Column="1" TickFrequency="5" Orientation="Horizontal" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsSelectionRangeEnabled="True" />
190-
<Slider Grid.Row="8" Grid.Column="1" TickFrequency="5" Orientation="Horizontal" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsEnabled="False" />
191-
180+
<wpf:TimePicker Grid.Row="5" Grid.Column="4" Is24Hours="True" x:Name="PresetTimePicker" VerticalAlignment="Top" Width="100" HorizontalAlignment="Left" Margin="0 8 0 8" />
192181
</Grid>
193182
</UserControl>

0 commit comments

Comments
 (0)