WPF Slider Show integral value TickFrequency="1" IsSnapToTickEnabled="True"

<Window x:Class="WpfApp85.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:WpfApp85"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <Style TargetType="Slider">
            <Setter Property="ToolTip" Value="Value"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="200"/>
            <RowDefinition Height="200"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <Slider x:Name="_slider1" Minimum="0" Maximum="100" />
            <TextBlock Text="{Binding Path=Value,ElementName=_slider1}"/>
        </StackPanel>
        <StackPanel Grid.Row="1">
            <Slider Grid.Row="3" x:Name="_intSlider" TickFrequency="1" IsSnapToTickEnabled="True" 
      Minimum="0" Maximum="100" 
      ToolTip="{Binding Path=Value,ElementName=_intSlider}"/>
            <TextBlock Grid.Row="4" Text="{Binding Path=Value,ElementName=_intSlider}"/>
        </StackPanel>
    </Grid>
</Window>

 

posted @ 2024-05-02 19:59  FredGrit  阅读(1)  评论(0编辑  收藏  举报