wabbajack/Wabbajack.App/Controls/LargeIconButton.axaml.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia;
using Avalonia.Controls;
using Material.Icons;
using ReactiveUI;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.App.Controls;
public partial class LargeIconButton : UserControl, IActivatableView
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
public static readonly StyledProperty<string> TextProperty =
AvaloniaProperty.Register<LargeIconButton, string>(nameof(Text));
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public static readonly StyledProperty<MaterialIconKind> IconProperty =
AvaloniaProperty.Register<LargeIconButton, MaterialIconKind>(nameof(IconProperty));
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public LargeIconButton()
{
InitializeComponent();
this.WhenActivated(dispose =>
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
this.WhenAnyValue(x => x.Icon)
.Where(x => x != default)
.BindTo(IconControl, x => x.Kind)
.DisposeWith(dispose);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
this.WhenAnyValue(x => x.Text)
.Where(x => x != default)
.BindTo(TextBlock, x => x.Text)
.DisposeWith(dispose);
});
}
public string Text
{
get => GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
public MaterialIconKind Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
2021-09-27 12:42:46 +00:00
}
}