Implemented pagination in profile list

This commit is contained in:
Robert committed 2023-07-21 23:10:50 +02:00
1 parent cfb39b986d
commit 7c19937bce
11 files changed
+210 -134

No files matched your search

@@ -51,18 +51,20 @@ public partial class Pagination : TemplatedControl
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property == ValueProperty)
if (e.Property == ValueProperty || e.Property == MaximumProperty)
Update();
}
private void NextButtonOnClick(object? sender, RoutedEventArgs e)
{
Value++;
if (Value < Maximum)
Value++;
}
private void PreviousButtonOnClick(object? sender, RoutedEventArgs e)
{
Value--;
if (Value > 1)
Value--;
}
private void Update()
@@ -1,6 +1,7 @@
using System;
using Avalonia;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
namespace Artemis.UI.Shared.Pagination;
@@ -10,7 +11,7 @@ public partial class Pagination : TemplatedControl
/// Defines the <see cref="Value" /> property
/// </summary>
public static readonly StyledProperty<int> ValueProperty =
AvaloniaProperty.Register<Pagination, int>(nameof(Value), 1, enableDataValidation: true, coerce: (p, v) => Math.Clamp(v, 1, ((Pagination) p).Maximum));
AvaloniaProperty.Register<Pagination, int>(nameof(Value), 1, defaultBindingMode: BindingMode.TwoWay);
/// <summary>
/// Defines the <see cref="Maximum" /> property
@@ -78,7 +78,8 @@ internal class Navigation
catch (Exception e)
{
Cancel();
_logger.Error(e, "Failed to navigate to {Path}", resolution.Path);
if (e is not TaskCanceledException)
_logger.Error(e, "Failed to navigate to {Path}", resolution.Path);
}
}
@@ -96,7 +97,8 @@ internal class Navigation
catch (Exception e)
{
Cancel();
_logger.Error(e, "Failed to navigate to {Path}", resolution.Path);
if (e is not TaskCanceledException)
_logger.Error(e, "Failed to navigate to {Path}", resolution.Path);
}
if (CancelIfRequested(args, "OnNavigating", screen))