最近实现了一个关于Slider的简单样式,可随Thumb位置实时显示Value值,效果如下面所示:

窗体xaml源码:
<Window x:Class="SliderDemo.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:SliderDemo"
mc:Ignorable="d" Background="#FF0258A4" WindowStartupLocation="CenterScreen"
Title="SliderDemo" Height="250" Width="400">
<Window.Resources>
<!--Slider样式-->
<Style x:Key="SliderThumb" TargetType="Thumb">
<Setter Property="Focusable" Va

本文介绍如何在WPF中创建一个Slider,其Thumb移动时能实时展示当前Value值。通过自定义样式,实现了滑块移动时数值的动态显示。
最低0.47元/天 解锁文章
1301





