Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit d8d7175

Browse files
1 parent 701453d commit d8d7175

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/CommunityToolkit/Xamarin.CommunityToolkit/Views/BaseTemplatedView.shared.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using Xamarin.Forms;
1+
using Xamarin.Forms;
32

43
namespace Xamarin.CommunityToolkit.UI.Views.Internals
54
{
@@ -9,9 +8,7 @@ namespace Xamarin.CommunityToolkit.UI.Views.Internals
98
/// <typeparam name="TControl">The type of the control that this template will be used for</typeparam>
109
public abstract class BaseTemplatedView<TControl> : TemplatedView where TControl : View, new()
1110
{
12-
TControl? control;
13-
14-
protected TControl Control => control ?? throw new NullReferenceException();
11+
protected TControl? Control { get; private set; }
1512

1613
/// <summary>
1714
/// Constructor of <see cref="BaseTemplatedView{TControl}" />
@@ -23,15 +20,15 @@ protected override void OnBindingContextChanged()
2320
{
2421
base.OnBindingContextChanged();
2522

26-
if (control != null)
23+
if (Control != null)
2724
Control.BindingContext = BindingContext;
2825
}
2926

3027
protected override void OnChildAdded(Element child)
3128
{
32-
if (control == null && child is TControl content)
29+
if (Control == null && child is TControl control)
3330
{
34-
control = content;
31+
Control = control;
3532
OnControlInitialized(Control);
3633
}
3734

src/CommunityToolkit/Xamarin.CommunityToolkit/Views/SideMenuView/SideMenuView.shared.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,18 +637,18 @@ void RemoveChild(View view)
637637
void RaiseMenuIfNeeded(View? menuView)
638638
{
639639
if (menuView != null && GetMenuAppearanceType(menuView) == SideMenuAppearanceType.SlideIn)
640-
Control.RaiseChild(menuView);
640+
Control?.RaiseChild(menuView);
641641
}
642642

643643
void OnLayoutChanged(object? sender, EventArgs e)
644644
{
645645
if (mainView == null)
646646
return;
647647

648-
using (Control.Batch())
648+
using (Control?.Batch())
649649
{
650-
Control.RaiseChild(mainView);
651-
Control.RaiseChild(overlayView);
650+
Control?.RaiseChild(mainView);
651+
Control?.RaiseChild(overlayView);
652652

653653
RaiseMenuIfNeeded(leftMenu);
654654
RaiseMenuIfNeeded(rightMenu);

0 commit comments

Comments
 (0)