diff --git a/src/Avalonia.Controls.Recycling/ControlRecycling.cs b/src/Avalonia.Controls.Recycling/ControlRecycling.cs
index fd328200..360389ca 100644
--- a/src/Avalonia.Controls.Recycling/ControlRecycling.cs
+++ b/src/Avalonia.Controls.Recycling/ControlRecycling.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using Avalonia.Controls.Recycling.Model;
using Avalonia.Controls.Templates;
@@ -64,14 +63,13 @@ public void Add(object data, object control)
///
public object? Build(object? data, object? existing, object? parent)
{
- if (data is null)
+ var key = data;
+ if (key is null)
{
return null;
}
- var key = data;
-
- if (TryToUseIdAsKey && data is IControlRecyclingIdProvider idProvider)
+ if (TryToUseIdAsKey && key is IControlRecyclingIdProvider idProvider)
{
if (!string.IsNullOrWhiteSpace(idProvider.GetControlRecyclingId()))
{
@@ -84,15 +82,15 @@ public void Add(object data, object control)
return control;
}
- var dataTemplate = (parent as Control)?.FindDataTemplate(data);
+ var dataTemplate = (parent as Control)?.FindDataTemplate(key);
- control = dataTemplate?.Build(data);
+ control = dataTemplate?.Build(key);
if (control is null)
{
return null;
}
- Add(key, control);
+ Add(key!, control);
return control;
}
diff --git a/src/Dock.Model/FactoryBase.Dockable.cs b/src/Dock.Model/FactoryBase.Dockable.cs
index b5a9330b..2cc4acb9 100644
--- a/src/Dock.Model/FactoryBase.Dockable.cs
+++ b/src/Dock.Model/FactoryBase.Dockable.cs
@@ -353,10 +353,10 @@ public void PreviewPinnedDockable(IDockable dockable)
Debug.Assert(rootDock.PinnedDock != null);
- RemoveAllVisibleDockables(rootDock.PinnedDock);
+ RemoveAllVisibleDockables(rootDock.PinnedDock!);
dockable.OriginalOwner = dockable.Owner;
- AddVisibleDockable(rootDock.PinnedDock, dockable);
+ AddVisibleDockable(rootDock.PinnedDock!, dockable);
}
///
@@ -527,7 +527,7 @@ public virtual void PinDockable(IDockable dockable)
else
{
Debug.Assert(dockable.OriginalOwner is IDock);
- var originalOwner = (IDock)dockable.OriginalOwner;
+ var originalOwner = (IDock)dockable.OriginalOwner!;
HidePreviewingDockables(rootDock);
AddVisibleDockable(originalOwner, dockable);
}