ソースコード
App.xaml
<Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application>
MainWindow.xaml
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="800"> <StackPanel Orientation="Vertical" Margin="5"> <TextBlock Name="value" Margin="10 " /> <Slider Name="slider" Width="75" Minimum="0" Maximum="255" ValueChanged="slider_ValueChanged" /> </StackPanel> </Window>
MainWindow.xaml.cs
using System.Windows; namespace WpfApplication2 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { value.Text = slider.Value.ToString("#"); } } }