Avalonia常用小控件Slider

1.项目下载地址:https://gitee.com/confusedkitten/avalonia-demo
2.UI库Semi.Avalonia,项目地址  https://github.com/irihitech/Semi.Avalonia\

样式预览:

Avalonia常用小控件Slider_第1张图片axaml代码 : 


	
		
			
				
					
						
					
				
			
		
	

 后台代码:

using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using AvaloniaDemo.ViewModels;
using System.Threading;

namespace AvaloniaDemo.Pages;

public partial class Slider : UserControl
{
    public SliderViewModel repeatModel = new SliderViewModel();

    public Slider()
    {
        InitializeComponent();
        this.DataContext = repeatModel;
    }
    /// 
    /// 进度条的值发生改变触发事件
    /// 
    /// 
    /// 
    private void SliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
    {
    }

    /// 
    /// 鼠标开始拖拽进度条
    /// 
    /// 
    /// 
    private void SliderPreviewMouseDown(object sender, PointerPressedEventArgs e)
    {

    }

    /// 
    /// 鼠标结束拖拽进度条
    /// 
    /// 
    /// 
    private void SliderPreviewMouseUp(object sender, PointerReleasedEventArgs e)
    {


    }

    /// 
    /// 提示
    /// 
    /// 
    /// 
    private void SliderProgress_MouseMove(object sender, PointerEventArgs e)
    {
        repeatModel.ToolTip = SliderProgress.Value.ToString("F2");

        var position = e.GetPosition(SliderProgress);
        repeatModel.VerticalOffset = position.Y - 80;
        repeatModel.HorizontalOffset = position.X - 600;
    }

    private void SliderProgress_LostMouseCapture(object sender, PointerCaptureLostEventArgs e)
    {
    }
}

你可能感兴趣的:(Avalonia,Avalonia,Slider)