-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
BorderHandler.Windows.cs
45 lines (36 loc) · 1.47 KB
/
BorderHandler.Windows.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace Microsoft.Maui.Handlers
{
public partial class BorderHandler : ViewHandler<IBorderView, ContentPanel>
{
public override void SetVirtualView(IView view)
{
base.SetVirtualView(view);
_ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class.");
_ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
PlatformView.CrossPlatformLayout = VirtualView;
}
static partial void UpdateContent(IBorderHandler handler)
{
_ = handler.PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class.");
_ = handler.VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
_ = handler.MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");
handler.PlatformView.Children.Clear();
handler.PlatformView.EnsureBorderPath();
if (handler.VirtualView.PresentedContent is IView view)
handler.PlatformView.Content = view.ToPlatform(handler.MauiContext);
}
protected override ContentPanel CreatePlatformView()
{
if (VirtualView == null)
{
throw new InvalidOperationException($"{nameof(VirtualView)} must be set to create a LayoutView");
}
var view = new ContentPanel
{
CrossPlatformLayout = VirtualView
};
return view;
}
}
}