diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
index 2eb8d62af8..78cad6f274 100644
--- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
+++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
@@ -16,6 +16,8 @@ using Avalonia.Interactivity;
using Avalonia.Logging;
using Avalonia.VisualTree;
+#nullable enable
+
namespace Avalonia.Controls.Primitives
{
///
@@ -61,8 +63,8 @@ namespace Avalonia.Controls.Primitives
///
/// Defines the property.
///
- public static readonly DirectProperty SelectedItemProperty =
- AvaloniaProperty.RegisterDirect(
+ public static readonly DirectProperty SelectedItemProperty =
+ AvaloniaProperty.RegisterDirect(
nameof(SelectedItem),
o => o.SelectedItem,
(o, v) => o.SelectedItem = v,
@@ -105,13 +107,13 @@ namespace Avalonia.Controls.Primitives
private static readonly IList Empty = Array.Empty
/// The event sender.
/// The event args.
- private void SelectedItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ private void SelectedItemsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (_syncingSelectedItems)
{
return;
}
- void Add(IList newItems, IList addedItems = null)
+ void Add(IList newItems, IList? addedItems = null)
{
foreach (var item in newItems)
{
@@ -865,8 +867,8 @@ namespace Avalonia.Controls.Primitives
}
}
- IList added = null;
- IList removed = null;
+ IList? added = null;
+ IList? removed = null;
switch (e.Action)
{
@@ -983,8 +985,8 @@ namespace Avalonia.Controls.Primitives
var item = ElementAt(Items, index);
var itemChanged = !Equals(item, oldItem);
var added = -1;
- HashSet removedIndexes = null;
- List removedItems = null;
+ HashSet? removedIndexes = null;
+ List? removedItems = null;
_selectedIndex = index;
_selectedItem = item;
@@ -1011,7 +1013,7 @@ namespace Avalonia.Controls.Primitives
}
else
{
- removedItems ??= new List();
+ removedItems ??= new List();
removedItems.Add(oldItem);
}
@@ -1050,7 +1052,7 @@ namespace Avalonia.Controls.Primitives
if (removedIndexes is object)
{
- removedItems ??= new List();
+ removedItems ??= new List();
foreach (var removed in removedIndexes)
{
@@ -1065,7 +1067,7 @@ namespace Avalonia.Controls.Primitives
var e = new SelectionChangedEventArgs(
SelectionChangedEvent,
- (IList)removedItems ?? Array.Empty(),
+ (IList?)removedItems ?? Array.Empty(),
added != -1 ? new[] { ElementAt(Items, added) } : Array.Empty());
RaiseEvent(e);
}