diff --git a/src/Avalonia.Input/ICloseable.cs b/src/Avalonia.Input/ICloseable.cs
index 3d6b95ddf4..d61b78dfa8 100644
--- a/src/Avalonia.Input/ICloseable.cs
+++ b/src/Avalonia.Input/ICloseable.cs
@@ -4,6 +4,6 @@ namespace Avalonia.Input
{
public interface ICloseable
{
- event EventHandler Closed;
+ event EventHandler? Closed;
}
}
diff --git a/src/Avalonia.Input/IInputElement.cs b/src/Avalonia.Input/IInputElement.cs
index 2245ff9986..d1552a3a2a 100644
--- a/src/Avalonia.Input/IInputElement.cs
+++ b/src/Avalonia.Input/IInputElement.cs
@@ -15,57 +15,57 @@ namespace Avalonia.Input
///
/// Occurs when the control receives focus.
///
- event EventHandler GotFocus;
+ event EventHandler? GotFocus;
///
/// Occurs when the control loses focus.
///
- event EventHandler LostFocus;
+ event EventHandler? LostFocus;
///
/// Occurs when a key is pressed while the control has focus.
///
- event EventHandler KeyDown;
+ event EventHandler? KeyDown;
///
/// Occurs when a key is released while the control has focus.
///
- event EventHandler KeyUp;
+ event EventHandler? KeyUp;
///
/// Occurs when a user typed some text while the control has focus.
///
- event EventHandler TextInput;
+ event EventHandler? TextInput;
///
/// Occurs when the pointer enters the control.
///
- event EventHandler PointerEnter;
+ event EventHandler? PointerEnter;
///
/// Occurs when the pointer leaves the control.
///
- event EventHandler PointerLeave;
+ event EventHandler? PointerLeave;
///
/// Occurs when the pointer is pressed over the control.
///
- event EventHandler PointerPressed;
+ event EventHandler? PointerPressed;
///
/// Occurs when the pointer moves over the control.
///
- event EventHandler PointerMoved;
+ event EventHandler? PointerMoved;
///
/// Occurs when the pointer is released over the control.
///
- event EventHandler PointerReleased;
+ event EventHandler? PointerReleased;
///
/// Occurs when the mouse wheel is scrolled over the control.
///
- event EventHandler PointerWheelChanged;
+ event EventHandler? PointerWheelChanged;
///
/// Gets or sets a value indicating whether the control can receive keyboard focus.
diff --git a/src/Avalonia.Input/IMainMenu.cs b/src/Avalonia.Input/IMainMenu.cs
index 781b176f5c..67b58c0ffc 100644
--- a/src/Avalonia.Input/IMainMenu.cs
+++ b/src/Avalonia.Input/IMainMenu.cs
@@ -27,6 +27,6 @@ namespace Avalonia.Input
///
/// Occurs when the main menu closes.
///
- event EventHandler MenuClosed;
+ event EventHandler? MenuClosed;
}
}
diff --git a/src/Avalonia.Input/INavigableContainer.cs b/src/Avalonia.Input/INavigableContainer.cs
index c52f3ac404..a67166a89d 100644
--- a/src/Avalonia.Input/INavigableContainer.cs
+++ b/src/Avalonia.Input/INavigableContainer.cs
@@ -12,6 +12,6 @@ namespace Avalonia.Input
/// The control from which movement begins.
/// Whether to wrap around when the first or last item is reached.
/// The control.
- IInputElement GetControl(NavigationDirection direction, IInputElement from, bool wrap);
+ IInputElement? GetControl(NavigationDirection direction, IInputElement? from, bool wrap);
}
}
diff --git a/src/Avalonia.Input/InputElement.cs b/src/Avalonia.Input/InputElement.cs
index 5aa1f1ff44..5ec0bd6ee4 100644
--- a/src/Avalonia.Input/InputElement.cs
+++ b/src/Avalonia.Input/InputElement.cs
@@ -233,7 +233,7 @@ namespace Avalonia.Input
///
/// Occurs when the control receives focus.
///
- public event EventHandler GotFocus
+ public event EventHandler? GotFocus
{
add { AddHandler(GotFocusEvent, value); }
remove { RemoveHandler(GotFocusEvent, value); }
@@ -242,7 +242,7 @@ namespace Avalonia.Input
///
/// Occurs when the control loses focus.
///
- public event EventHandler LostFocus
+ public event EventHandler? LostFocus
{
add { AddHandler(LostFocusEvent, value); }
remove { RemoveHandler(LostFocusEvent, value); }
@@ -251,7 +251,7 @@ namespace Avalonia.Input
///
/// Occurs when a key is pressed while the control has focus.
///
- public event EventHandler KeyDown
+ public event EventHandler? KeyDown
{
add { AddHandler(KeyDownEvent, value); }
remove { RemoveHandler(KeyDownEvent, value); }
@@ -260,7 +260,7 @@ namespace Avalonia.Input
///
/// Occurs when a key is released while the control has focus.
///
- public event EventHandler KeyUp
+ public event EventHandler? KeyUp
{
add { AddHandler(KeyUpEvent, value); }
remove { RemoveHandler(KeyUpEvent, value); }
@@ -269,7 +269,7 @@ namespace Avalonia.Input
///
/// Occurs when a user typed some text while the control has focus.
///
- public event EventHandler TextInput
+ public event EventHandler? TextInput
{
add { AddHandler(TextInputEvent, value); }
remove { RemoveHandler(TextInputEvent, value); }
@@ -278,7 +278,7 @@ namespace Avalonia.Input
///
/// Occurs when an input element gains input focus and input method is looking for the corresponding client
///
- public event EventHandler TextInputMethodClientRequested
+ public event EventHandler? TextInputMethodClientRequested
{
add { AddHandler(TextInputMethodClientRequestedEvent, value); }
remove { RemoveHandler(TextInputMethodClientRequestedEvent, value); }
@@ -287,7 +287,7 @@ namespace Avalonia.Input
///
/// Occurs when an input element gains input focus and input method is asking for required content options
///
- public event EventHandler TextInputOptionsQuery
+ public event EventHandler? TextInputOptionsQuery
{
add { AddHandler(TextInputOptionsQueryEvent, value); }
remove { RemoveHandler(TextInputOptionsQueryEvent, value); }
@@ -296,7 +296,7 @@ namespace Avalonia.Input
///
/// Occurs when the pointer enters the control.
///
- public event EventHandler PointerEnter
+ public event EventHandler? PointerEnter
{
add { AddHandler(PointerEnterEvent, value); }
remove { RemoveHandler(PointerEnterEvent, value); }
@@ -305,7 +305,7 @@ namespace Avalonia.Input
///
/// Occurs when the pointer leaves the control.
///
- public event EventHandler PointerLeave
+ public event EventHandler? PointerLeave
{
add { AddHandler(PointerLeaveEvent, value); }
remove { RemoveHandler(PointerLeaveEvent, value); }
@@ -314,7 +314,7 @@ namespace Avalonia.Input
///
/// Occurs when the pointer moves over the control.
///
- public event EventHandler PointerMoved
+ public event EventHandler? PointerMoved
{
add { AddHandler(PointerMovedEvent, value); }
remove { RemoveHandler(PointerMovedEvent, value); }
@@ -323,7 +323,7 @@ namespace Avalonia.Input
///
/// Occurs when the pointer is pressed over the control.
///
- public event EventHandler PointerPressed
+ public event EventHandler? PointerPressed
{
add { AddHandler(PointerPressedEvent, value); }
remove { RemoveHandler(PointerPressedEvent, value); }
@@ -332,7 +332,7 @@ namespace Avalonia.Input
///
/// Occurs when the pointer is released over the control.
///
- public event EventHandler PointerReleased
+ public event EventHandler? PointerReleased
{
add { AddHandler(PointerReleasedEvent, value); }
remove { RemoveHandler(PointerReleasedEvent, value); }
@@ -342,7 +342,7 @@ namespace Avalonia.Input
/// Occurs when the control or its child control loses the pointer capture for any reason,
/// event will not be triggered for a parent control if capture was transferred to another child of that parent control
///
- public event EventHandler PointerCaptureLost
+ public event EventHandler? PointerCaptureLost
{
add => AddHandler(PointerCaptureLostEvent, value);
remove => RemoveHandler(PointerCaptureLostEvent, value);
@@ -351,7 +351,7 @@ namespace Avalonia.Input
///
/// Occurs when the mouse is scrolled over the control.
///
- public event EventHandler PointerWheelChanged
+ public event EventHandler? PointerWheelChanged
{
add { AddHandler(PointerWheelChangedEvent, value); }
remove { RemoveHandler(PointerWheelChangedEvent, value); }
@@ -360,7 +360,7 @@ namespace Avalonia.Input
///
/// Occurs when a tap gesture occurs on the control.
///
- public event EventHandler Tapped
+ public event EventHandler? Tapped
{
add { AddHandler(TappedEvent, value); }
remove { RemoveHandler(TappedEvent, value); }
@@ -369,7 +369,7 @@ namespace Avalonia.Input
///
/// Occurs when a double-tap gesture occurs on the control.
///
- public event EventHandler DoubleTapped
+ public event EventHandler? DoubleTapped
{
add { AddHandler(DoubleTappedEvent, value); }
remove { RemoveHandler(DoubleTappedEvent, value); }
diff --git a/src/Avalonia.Input/TextInput/ITextInputMethodClient.cs b/src/Avalonia.Input/TextInput/ITextInputMethodClient.cs
index 2b5d8958cc..5af8fe0251 100644
--- a/src/Avalonia.Input/TextInput/ITextInputMethodClient.cs
+++ b/src/Avalonia.Input/TextInput/ITextInputMethodClient.cs
@@ -12,7 +12,7 @@ namespace Avalonia.Input.TextInput
///
/// Should be fired when cursor rectangle is changed inside the TextViewVisual
///
- event EventHandler CursorRectangleChanged;
+ event EventHandler? CursorRectangleChanged;
///
/// The visual that's showing the text
///
@@ -20,7 +20,7 @@ namespace Avalonia.Input.TextInput
///
/// Should be fired when text-hosting visual is changed
///
- event EventHandler TextViewVisualChanged;
+ event EventHandler? TextViewVisualChanged;
///
/// Indicates if TextViewVisual is capable of displaying non-committed input on the cursor position
///
@@ -40,15 +40,15 @@ namespace Avalonia.Input.TextInput
///
/// Should be fired when surrounding text changed
///
- event EventHandler SurroundingTextChanged;
+ event EventHandler? SurroundingTextChanged;
///
/// Returns the text before the cursor. Must return a non-empty string if cursor is not at the beginning of the text entry
///
- string TextBeforeCursor { get; }
+ string? TextBeforeCursor { get; }
///
/// Returns the text before the cursor. Must return a non-empty string if cursor is not at the end of the text entry
///
- string TextAfterCursor { get; }
+ string? TextAfterCursor { get; }
}
public struct TextInputMethodSurroundingText
diff --git a/src/Avalonia.Input/TextInput/ITextInputMethodImpl.cs b/src/Avalonia.Input/TextInput/ITextInputMethodImpl.cs
index 0069314d28..2d24ed30a0 100644
--- a/src/Avalonia.Input/TextInput/ITextInputMethodImpl.cs
+++ b/src/Avalonia.Input/TextInput/ITextInputMethodImpl.cs
@@ -10,6 +10,6 @@ namespace Avalonia.Input.TextInput
public interface ITextInputMethodRoot : IInputRoot
{
- ITextInputMethodImpl InputMethod { get; }
+ ITextInputMethodImpl? InputMethod { get; }
}
}
diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs
index 2497150b1a..75f74ed3b3 100644
--- a/src/Avalonia.Interactivity/Interactive.cs
+++ b/src/Avalonia.Interactivity/Interactive.cs
@@ -50,12 +50,14 @@ namespace Avalonia.Interactivity
/// Whether handled events should also be listened for.
public void AddHandler(
RoutedEvent routedEvent,
- EventHandler handler,
+ EventHandler? handler,
RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble,
bool handledEventsToo = false) where TEventArgs : RoutedEventArgs
{
routedEvent = routedEvent ?? throw new ArgumentNullException(nameof(routedEvent));
- handler = handler ?? throw new ArgumentNullException(nameof(handler));
+
+ if (handler is null)
+ return;
static void InvokeAdapter(Delegate baseHandler, object sender, RoutedEventArgs args)
{
@@ -99,10 +101,11 @@ namespace Avalonia.Interactivity
/// The type of the event's args.
/// The routed event.
/// The handler.
- public void RemoveHandler(RoutedEvent routedEvent, EventHandler handler)
+ public void RemoveHandler(RoutedEvent routedEvent, EventHandler? handler)
where TEventArgs : RoutedEventArgs
{
- RemoveHandler(routedEvent, (Delegate)handler);
+ if (handler is not null)
+ RemoveHandler(routedEvent, (Delegate)handler);
}
///
diff --git a/src/Avalonia.Layout/ElementManager.cs b/src/Avalonia.Layout/ElementManager.cs
index 9a033ca447..048e8eebee 100644
--- a/src/Avalonia.Layout/ElementManager.cs
+++ b/src/Avalonia.Layout/ElementManager.cs
@@ -263,7 +263,7 @@ namespace Avalonia.Layout
return intersects;
}
- public void DataSourceChanged(object source, NotifyCollectionChangedEventArgs args)
+ public void DataSourceChanged(object? source, NotifyCollectionChangedEventArgs args)
{
if (_realizedElements.Count > 0)
{
diff --git a/src/Avalonia.Layout/FlowLayoutAlgorithm.cs b/src/Avalonia.Layout/FlowLayoutAlgorithm.cs
index 40b392225f..3e516b4f97 100644
--- a/src/Avalonia.Layout/FlowLayoutAlgorithm.cs
+++ b/src/Avalonia.Layout/FlowLayoutAlgorithm.cs
@@ -135,7 +135,7 @@ namespace Avalonia.Layout
}
public void OnItemsSourceChanged(
- object source,
+ object? source,
NotifyCollectionChangedEventArgs args,
VirtualizingLayoutContext context)
{
diff --git a/src/Avalonia.Layout/LayoutHelper.cs b/src/Avalonia.Layout/LayoutHelper.cs
index 71a2fa085b..d4154a6d0c 100644
--- a/src/Avalonia.Layout/LayoutHelper.cs
+++ b/src/Avalonia.Layout/LayoutHelper.cs
@@ -33,13 +33,13 @@ namespace Avalonia.Layout
MathUtilities.Clamp(constraints.Height, minmax.MinHeight, minmax.MaxHeight));
}
- public static Size MeasureChild(ILayoutable control, Size availableSize, Thickness padding,
+ public static Size MeasureChild(ILayoutable? control, Size availableSize, Thickness padding,
Thickness borderThickness)
{
return MeasureChild(control, availableSize, padding + borderThickness);
}
- public static Size MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
+ public static Size MeasureChild(ILayoutable? control, Size availableSize, Thickness padding)
{
if (control != null)
{
@@ -50,12 +50,12 @@ namespace Avalonia.Layout
return new Size(padding.Left + padding.Right, padding.Bottom + padding.Top);
}
- public static Size ArrangeChild(ILayoutable child, Size availableSize, Thickness padding, Thickness borderThickness)
+ public static Size ArrangeChild(ILayoutable? child, Size availableSize, Thickness padding, Thickness borderThickness)
{
return ArrangeChild(child, availableSize, padding + borderThickness);
}
- public static Size ArrangeChild(ILayoutable child, Size availableSize, Thickness padding)
+ public static Size ArrangeChild(ILayoutable? child, Size availableSize, Thickness padding)
{
child?.Arrange(new Rect(availableSize).Deflate(padding));
diff --git a/src/Avalonia.Layout/StackLayout.cs b/src/Avalonia.Layout/StackLayout.cs
index 32e9c4dc8e..c63fe5e405 100644
--- a/src/Avalonia.Layout/StackLayout.cs
+++ b/src/Avalonia.Layout/StackLayout.cs
@@ -313,7 +313,7 @@ namespace Avalonia.Layout
return new Size(value.Width, value.Height);
}
- protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object source, NotifyCollectionChangedEventArgs args)
+ protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object? source, NotifyCollectionChangedEventArgs args)
{
GetFlowAlgorithm(context).OnItemsSourceChanged(source, args, context);
// Always invalidate layout to keep the view accurate.
diff --git a/src/Avalonia.Layout/UniformGridLayout.cs b/src/Avalonia.Layout/UniformGridLayout.cs
index 508113834a..3b82ece886 100644
--- a/src/Avalonia.Layout/UniformGridLayout.cs
+++ b/src/Avalonia.Layout/UniformGridLayout.cs
@@ -461,7 +461,7 @@ namespace Avalonia.Layout
return new Size(value.Width, value.Height);
}
- protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object source, NotifyCollectionChangedEventArgs args)
+ protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object? source, NotifyCollectionChangedEventArgs args)
{
GetFlowAlgorithm(context).OnItemsSourceChanged(source, args, context);
// Always invalidate layout to keep the view accurate.
diff --git a/src/Avalonia.Layout/VirtualizingLayout.cs b/src/Avalonia.Layout/VirtualizingLayout.cs
index 15c7749dfe..0cae889026 100644
--- a/src/Avalonia.Layout/VirtualizingLayout.cs
+++ b/src/Avalonia.Layout/VirtualizingLayout.cs
@@ -35,7 +35,7 @@ namespace Avalonia.Layout
///
public void OnItemsChanged(
VirtualizingLayoutContext context,
- object source,
+ object? source,
NotifyCollectionChangedEventArgs args) => OnItemsChangedCore(context, source, args);
///
@@ -113,7 +113,7 @@ namespace Avalonia.Layout
/// Data about the collection change.
protected internal virtual void OnItemsChangedCore(
VirtualizingLayoutContext context,
- object source,
+ object? source,
NotifyCollectionChangedEventArgs args) => InvalidateMeasure();
}
}
diff --git a/src/Avalonia.Layout/WrapLayout/WrapLayout.cs b/src/Avalonia.Layout/WrapLayout/WrapLayout.cs
index d12a83d1d7..aab0272f37 100644
--- a/src/Avalonia.Layout/WrapLayout/WrapLayout.cs
+++ b/src/Avalonia.Layout/WrapLayout/WrapLayout.cs
@@ -86,7 +86,7 @@ namespace Avalonia.Layout
}
///
- protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object source, NotifyCollectionChangedEventArgs args)
+ protected internal override void OnItemsChangedCore(VirtualizingLayoutContext context, object? source, NotifyCollectionChangedEventArgs args)
{
var state = (WrapLayoutState)context.LayoutState!;
diff --git a/src/Avalonia.Styling/Controls/IResourceHost.cs b/src/Avalonia.Styling/Controls/IResourceHost.cs
index fed9359d94..ea34a8b39a 100644
--- a/src/Avalonia.Styling/Controls/IResourceHost.cs
+++ b/src/Avalonia.Styling/Controls/IResourceHost.cs
@@ -15,7 +15,7 @@ namespace Avalonia.Controls
///
/// Raised when the resources change on the element or an ancestor of the element.
///
- event EventHandler ResourcesChanged;
+ event EventHandler? ResourcesChanged;
///
/// Notifies the resource host that one or more of its hosted resources has changed.
diff --git a/src/Avalonia.Styling/Controls/IResourceProvider.cs b/src/Avalonia.Styling/Controls/IResourceProvider.cs
index 27a8c2da68..fe6c4e48e4 100644
--- a/src/Avalonia.Styling/Controls/IResourceProvider.cs
+++ b/src/Avalonia.Styling/Controls/IResourceProvider.cs
@@ -25,7 +25,7 @@ namespace Avalonia.Controls
///
/// Raised when the of the resource provider changes.
///
- event EventHandler OwnerChanged;
+ event EventHandler? OwnerChanged;
///
/// Adds an owner to the resource provider.
diff --git a/src/Avalonia.Styling/LogicalTree/LogicalTreeAttachmentEventArgs.cs b/src/Avalonia.Styling/LogicalTree/LogicalTreeAttachmentEventArgs.cs
index 826fc5b2a4..b07b7f8ffe 100644
--- a/src/Avalonia.Styling/LogicalTree/LogicalTreeAttachmentEventArgs.cs
+++ b/src/Avalonia.Styling/LogicalTree/LogicalTreeAttachmentEventArgs.cs
@@ -17,7 +17,7 @@ namespace Avalonia.LogicalTree
public LogicalTreeAttachmentEventArgs(
ILogicalRoot root,
ILogical source,
- ILogical parent)
+ ILogical? parent)
{
Root = root ?? throw new ArgumentNullException(nameof(root));
Source = source ?? throw new ArgumentNullException(nameof(source));
@@ -47,6 +47,6 @@ namespace Avalonia.LogicalTree
/// detachment, holds the old logical parent of . If the detachment event
/// was caused by a top-level control being closed, then this property will be null.
///
- public ILogical Parent { get; }
+ public ILogical? Parent { get; }
}
}
diff --git a/src/Avalonia.Styling/Styling/IGlobalStyles.cs b/src/Avalonia.Styling/Styling/IGlobalStyles.cs
index 91a04932de..ab24e3138c 100644
--- a/src/Avalonia.Styling/Styling/IGlobalStyles.cs
+++ b/src/Avalonia.Styling/Styling/IGlobalStyles.cs
@@ -13,11 +13,11 @@ namespace Avalonia.Styling
///
/// Raised when styles are added to or a nested styles collection.
///
- public event Action> GlobalStylesAdded;
+ public event Action>? GlobalStylesAdded;
///
/// Raised when styles are removed from or a nested styles collection.
///
- public event Action> GlobalStylesRemoved;
+ public event Action>? GlobalStylesRemoved;
}
}
diff --git a/src/Avalonia.Visuals/Media/DrawingContext.cs b/src/Avalonia.Visuals/Media/DrawingContext.cs
index 2fbef8c89f..5584e52655 100644
--- a/src/Avalonia.Visuals/Media/DrawingContext.cs
+++ b/src/Avalonia.Visuals/Media/DrawingContext.cs
@@ -119,7 +119,7 @@ namespace Avalonia.Media
/// The fill brush.
/// The stroke pen.
/// The geometry.
- public void DrawGeometry(IBrush brush, IPen pen, Geometry geometry)
+ public void DrawGeometry(IBrush? brush, IPen? pen, Geometry geometry)
{
if (geometry.PlatformImpl is not null)
DrawGeometry(brush, pen, geometry.PlatformImpl);
@@ -131,7 +131,7 @@ namespace Avalonia.Media
/// The fill brush.
/// The stroke pen.
/// The geometry.
- public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry)
+ public void DrawGeometry(IBrush? brush, IPen? pen, IGeometryImpl geometry)
{
_ = geometry ?? throw new ArgumentNullException(nameof(geometry));
diff --git a/src/Avalonia.Visuals/Platform/LockedFramebuffer.cs b/src/Avalonia.Visuals/Platform/LockedFramebuffer.cs
index 9ebfe290e1..b9094d9e14 100644
--- a/src/Avalonia.Visuals/Platform/LockedFramebuffer.cs
+++ b/src/Avalonia.Visuals/Platform/LockedFramebuffer.cs
@@ -4,10 +4,10 @@ namespace Avalonia.Platform
{
public class LockedFramebuffer : ILockedFramebuffer
{
- private readonly Action _onDispose;
+ private readonly Action? _onDispose;
public LockedFramebuffer(IntPtr address, PixelSize size, int rowBytes, Vector dpi, PixelFormat format,
- Action onDispose)
+ Action? onDispose)
{
_onDispose = onDispose;
Address = address;
diff --git a/src/Avalonia.Visuals/VisualTree/IHostedVisualTreeRoot.cs b/src/Avalonia.Visuals/VisualTree/IHostedVisualTreeRoot.cs
index cb757e0a57..aec093c574 100644
--- a/src/Avalonia.Visuals/VisualTree/IHostedVisualTreeRoot.cs
+++ b/src/Avalonia.Visuals/VisualTree/IHostedVisualTreeRoot.cs
@@ -11,6 +11,6 @@ namespace Avalonia.VisualTree
///
/// The visual tree host.
///
- IVisual Host { get; }
+ IVisual? Host { get; }
}
}
diff --git a/src/Avalonia.Visuals/VisualTree/IVisualTreeHost.cs b/src/Avalonia.Visuals/VisualTree/IVisualTreeHost.cs
index 01212b238d..e47377063f 100644
--- a/src/Avalonia.Visuals/VisualTree/IVisualTreeHost.cs
+++ b/src/Avalonia.Visuals/VisualTree/IVisualTreeHost.cs
@@ -14,6 +14,6 @@ namespace Avalonia.VisualTree
///
/// The root of the hosted visual tree.
///
- IVisual Root { get; }
+ IVisual? Root { get; }
}
}