Browse Source

changed MenuItem Icon to properly set :icon pseudo class as long as value is not null (#19075)

pull/19083/head
Paillat Laszlo 8 months ago
committed by GitHub
parent
commit
6e6477d406
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 25
      src/Avalonia.Controls/MenuItem.cs

25
src/Avalonia.Controls/MenuItem.cs

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Windows.Input;
using Avalonia.Automation;
@ -571,7 +570,7 @@ namespace Avalonia.Controls
}
}
}
/// <summary>
/// Closes all submenus of the menu item.
/// </summary>
@ -609,12 +608,12 @@ namespace Avalonia.Controls
}
}
private static void OnAccessKeyPressed(MenuItem sender, AccessKeyPressedEventArgs e)
{
if (e is not { Handled: false, Target: null })
if (e is not { Handled: false, Target: null })
return;
e.Target = sender;
e.Handled = true;
}
@ -789,15 +788,23 @@ namespace Avalonia.Controls
{
var (oldValue, newValue) = e.GetOldAndNewValue<object?>();
if (oldValue is ILogical oldLogical)
if (oldValue is { })
{
LogicalChildren.Remove(oldLogical);
if (oldValue is ILogical oldLogical)
{
LogicalChildren.Remove(oldLogical);
}
PseudoClasses.Remove(":icon");
}
if (newValue is ILogical newLogical)
if (newValue is { })
{
LogicalChildren.Add(newLogical);
if (newValue is ILogical newLogical)
{
LogicalChildren.Add(newLogical);
}
PseudoClasses.Add(":icon");
}
}

Loading…
Cancel
Save