SliderTest.axaml代码

<Window xmlns="https://github.com/avaloniaui"
        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"
        Height="252" Width="482"
        x:Class="AvaloniaUI.SliderTest"
        Title="SliderTest">
    <StackPanel>
        <TextBlock Margin="10" TextWrapping="Wrap">
            Try clicking on either side of the thumb and holding down
            the mouse button. Value will be <InlineUIContainer>
                <TextBlock Text="{Binding #slider.Value}"/>
            </InlineUIContainer>
        </TextBlock>

        <Slider Name="slider" Margin="10" TickFrequency="1" TickPlacement="TopLeft" Maximum="10" IsSnapToTickEnabled="True">
        </Slider>
        
    </StackPanel>
</Window>

SliderTest.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AvaloniaUI;

public partial class SliderTest : Window
{
    public SliderTest()
    {
        InitializeComponent();
    }
}

运行效果

image

 

posted on 2025-07-25 11:29  dalgleish  阅读(12)  评论(0)    收藏  举报