diff --git a/Text-Grab/Controls/InlineChipElement.cs b/Text-Grab/Controls/InlineChipElement.cs index da12f279..beab9d6b 100644 --- a/Text-Grab/Controls/InlineChipElement.cs +++ b/Text-Grab/Controls/InlineChipElement.cs @@ -31,6 +31,8 @@ public string Value public event EventHandler? RemoveRequested; + private Button? _removeButton; + static InlineChipElement() { DefaultStyleKeyProperty.OverrideMetadata( @@ -42,7 +44,15 @@ public override void OnApplyTemplate() { base.OnApplyTemplate(); - if (GetTemplateChild(PartRemoveButton) is Button removeButton) - removeButton.Click += (s, e) => RemoveRequested?.Invoke(this, EventArgs.Empty); + if (_removeButton is not null) + _removeButton.Click -= RemoveButton_Click; + + _removeButton = GetTemplateChild(PartRemoveButton) as Button; + + if (_removeButton is not null) + _removeButton.Click += RemoveButton_Click; } + + private void RemoveButton_Click(object sender, RoutedEventArgs e) + => RemoveRequested?.Invoke(this, EventArgs.Empty); } diff --git a/Text-Grab/Controls/InlinePickerRichTextBox.cs b/Text-Grab/Controls/InlinePickerRichTextBox.cs index a3c34dbe..0957745d 100644 --- a/Text-Grab/Controls/InlinePickerRichTextBox.cs +++ b/Text-Grab/Controls/InlinePickerRichTextBox.cs @@ -50,7 +50,7 @@ public class InlinePickerRichTextBox : RichTextBox public IEnumerable ItemsSource { - get => (IEnumerable)GetValue(ItemsSourceProperty); + get => (IEnumerable?)GetValue(ItemsSourceProperty) ?? []; set => SetValue(ItemsSourceProperty, value); } diff --git a/Text-Grab/Views/FullscreenGrab.xaml b/Text-Grab/Views/FullscreenGrab.xaml index 90717c49..35902a56 100644 --- a/Text-Grab/Views/FullscreenGrab.xaml +++ b/Text-Grab/Views/FullscreenGrab.xaml @@ -95,7 +95,7 @@ x:Name="FreeformSelectionMenuItem" Click="SelectionStyleMenuItem_Click" Header="Freeform - Draw any shape" - InputGestureText="P" + InputGestureText="D" IsCheckable="True" Tag="Freeform" />