|
@@ -21,19 +21,27 @@ namespace InABox.Avalonia.Components;
|
|
|
|
|
|
public partial class ButtonStrip : TemplatedControl
|
|
public partial class ButtonStrip : TemplatedControl
|
|
{
|
|
{
|
|
- public static StyledProperty<IBrush?> SelectedBackgroundProperty = AvaloniaProperty.Register<ButtonStripItem, IBrush?>(
|
|
|
|
|
|
+ public static readonly StyledProperty<IBrush?> SelectedBackgroundProperty = AvaloniaProperty.Register<ButtonStripItem, IBrush?>(
|
|
nameof(SelectedBackground));
|
|
nameof(SelectedBackground));
|
|
- public static StyledProperty<IBrush?> SelectedForegroundProperty = AvaloniaProperty.Register<ButtonStripItem, IBrush?>(
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<IBrush?> SelectedForegroundProperty = AvaloniaProperty.Register<ButtonStripItem, IBrush?>(
|
|
nameof(SelectedForeground));
|
|
nameof(SelectedForeground));
|
|
- public static StyledProperty<double> ItemSpacingProperty = AvaloniaProperty.Register<ButtonStripItem, double>(
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<double> ItemSpacingProperty = AvaloniaProperty.Register<ButtonStripItem, double>(
|
|
nameof(ItemSpacing));
|
|
nameof(ItemSpacing));
|
|
- public static StyledProperty<ObservableCollection<ButtonStripItem>> ItemsProperty =
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<ObservableCollection<ButtonStripItem>> ItemsProperty =
|
|
AvaloniaProperty.Register<ButtonStripItem, ObservableCollection<ButtonStripItem>>(nameof(Items));
|
|
AvaloniaProperty.Register<ButtonStripItem, ObservableCollection<ButtonStripItem>>(nameof(Items));
|
|
- public static StyledProperty<IEnumerable?> ItemsSourceProperty =
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<IEnumerable?> ItemsSourceProperty =
|
|
AvaloniaProperty.Register<ButtonStripItem, IEnumerable?>(nameof(ItemsSource));
|
|
AvaloniaProperty.Register<ButtonStripItem, IEnumerable?>(nameof(ItemsSource));
|
|
- public static StyledProperty<ICommand> SelectedCommandProperty = AvaloniaProperty.Register<ButtonStrip, ICommand>(nameof(SelectedCommand));
|
|
|
|
- public static StyledProperty<object?> SelectedItemProperty = AvaloniaProperty.Register<ButtonStrip, object?>(nameof(SelectedItem));
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<ICommand> SelectedCommandProperty =
|
|
|
|
+ AvaloniaProperty.Register<ButtonStrip, ICommand>(nameof(SelectedCommand));
|
|
|
|
+
|
|
|
|
+ public static readonly StyledProperty<object?> SelectedItemProperty =
|
|
|
|
+ AvaloniaProperty.Register<ButtonStrip, object?>(nameof(SelectedItem));
|
|
|
|
+
|
|
public IBrush? SelectedBackground
|
|
public IBrush? SelectedBackground
|
|
{
|
|
{
|
|
get => GetValue(SelectedBackgroundProperty);
|
|
get => GetValue(SelectedBackgroundProperty);
|
|
@@ -87,6 +95,12 @@ public partial class ButtonStrip : TemplatedControl
|
|
set => SetValue(SelectedItemProperty, value);
|
|
set => SetValue(SelectedItemProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public int SelectedIndex
|
|
|
|
+ {
|
|
|
|
+ get => SelectedButton != null ? Items.IndexOf(SelectedButton) : -1;
|
|
|
|
+ set => SelectedButton = Items[value];
|
|
|
|
+ }
|
|
|
|
+
|
|
public event EventHandler? SelectionChanged;
|
|
public event EventHandler? SelectionChanged;
|
|
|
|
|
|
static ButtonStrip()
|
|
static ButtonStrip()
|