728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="Slider 엘리먼트 : 커스텀 슬라이더 사용하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Style x:Key="SliderRepeatButtonStyleKey" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Rectangle Fill="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HorizontalSliderThumbStyleKey" TargetType="{x:Type Thumb}">
<Setter Property="Width" Value="14" />
<Setter Property="Height" Value="14" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Focusable" Value="false" />
<Setter Property="Foreground" Value="Gray" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Ellipse
StrokeThickness="0.8"
Stroke="#ff5e5d5d"
Fill="#ffaed1ed" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Slider}">
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#ffc4c4c4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Border
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition
MinHeight="{TemplateBinding MinHeight}"
Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TickBar Grid.Row="0"
Height="4"
Fill="{TemplateBinding Foreground}"
Placement="Top"
Visibility="Collapsed" />
<TickBar Grid.Row="2"
Height="4"
Fill="{TemplateBinding Foreground}"
Placement="Bottom"
Visibility="Collapsed" />
<Border Grid.Row="1"
Margin="5,0"
Height="5.0"
CornerRadius="1"
VerticalAlignment="center">
<Grid>
<Border
CornerRadius="0.5"
Background="#fff7f4f4"
Opacity="0.215" />
<Border
Margin="0 0 0.3 0.3"
CornerRadius="0.5"
Background="#ff132e50"
Opacity="0.715" />
</Grid>
</Border>
<Track Name="PART_Track" Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton
Style="{StaticResource SliderRepeatButtonStyleKey}"
Command="{x:Static Slider.DecreaseLarge}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton
Style="{StaticResource SliderRepeatButtonStyleKey}"
Command="{x:Static Slider.IncreaseLarge}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource HorizontalSliderThumbStyleKey}" />
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="0.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<Slider
Width="300"
Height="20">
</Slider>
</Grid>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 워드 클라우드(Word Cloud) 이미지 만들기 (0) | 2021.02.19 |
---|---|
[C#/WPF] 로딩 패널 표시하기 (0) | 2021.02.18 |
[C#/WPF] BitmapImage 클래스 : 바이트 배열에서 비트맵 이미지 구하기 (0) | 2021.02.18 |
[C#/WPF] BitmapSource 클래스 : 바이트 배열에서 비트맵 소스 구하기 (0) | 2021.02.18 |
[C#/WPF] BitmapImage 클래스 : 바이트 배열 구하기 (0) | 2021.02.17 |
[C#/WPF] Slider 엘리먼트 : 커스텀 슬라이더 사용하기 (0) | 2021.02.16 |
[C#/WPF] 진행 컨트롤 사용하기 (0) | 2021.02.16 |
[C#/WPF] VisualStateManager 엘리먼트 : 컨트롤 템플리트 내에서 사용하기 (0) | 2021.02.15 |
[C#/WPF] FlowDocument 클래스 : RTF 파일 로드하기 (0) | 2021.02.15 |
[C#/WPF] FlowDocument 클래스 : RTF 파일을 XAML로 변환하기 (0) | 2021.02.15 |
[C#/WPF] DependencyProperty 클래스 : OverrideMetadata 메소드를 사용해 표준 의존 속성 디폴트 값 설정하기 (0) | 2021.02.14 |
댓글을 달아 주세요