Visual Studio/WPF > 컨트롤 > Slider > SmallChange, LargeChange 속성

운영 환경
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

@ WPF 4.5 입문 by 오타 카즈키
No.4550/9985

4.6.5.2 값의 증감폭 설정

SmallChange, LargeChange라는 속성을 사용하는 것 같습니다.
사용해 보았다.

XAML
<Window x:Class="_170426_t0930_radioButton.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_170426_t0930_radioButton"
        mc:Ignorable="d"
        Title="MainWindow" Height="400" Width="525">
    <Grid Margin="0,30,0,0">
        <StackPanel>
            <Slider x:Name="slider1" Margin="0, 10" 
                    Maximum="100"
                    SmallChange="5" LargeChange="20"
                    ValueChanged="slider1_ValueChanged"/>
            <Slider x:Name="slider2" Margin="0, 10"
                    Maximum="200"
                    />
            <Slider x:Name="slider3" Margin="0, 10"
                    Maximum="400"
                    />
            <Button Content="Turtle" Margin="0, 5" Click="Button_Click"/>
            <Button Content="Rabbit" Margin="0, 5" Click="Button_Click_1"/>
        </StackPanel>
    </Grid>
</Window>

MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _170426_t0930_radioButton
{
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            slider2.Value = slider1.Value;
            slider3.Value = slider1.Value;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            slider1.Value += slider1.SmallChange;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            slider1.Value += slider1.LargeChange;
        }
    }
}

버튼에 의해 Slider1의 값을 LargeChange, SmallChange의 값으로 변경한다.
Turtle(작은), Rabbit(큰) 증가.

이런 사용법이 올바른지는 불명.

좋은 웹페이지 즐겨찾기