Custom Controls이 포함된 Page를 열 때 InvalidOperationExceptiond : Context cannot be null here 이 발생합니다.
// ViewHandlerOf.Android code...
public Context Context => MauiContext?.Context ?? throw new InvalidOperationException($"Context cannot be null here");
// runtime error : Navigating to `Custom Controls`
System.InvalidOperationException: Context cannot be null here
Custom Controls에서 발생하는 Exception입니다.
ViewHandler throw new InvalidOperationException 코드 링크입니다.
질문입니다.
Handler가 없어서 발생하는 문제 일까요?
=> Ex) class ViewHandler<CustomControls, TPlatformView: null> CustomControls could not recognize the platform
Context가 어떤 경우에 Null이 될 수 있을까요?
+++
Handler를 생성하는 방법은? (예제를 봤을 때 무엇을 상속 받아서 구현해야 하는지 모르겠네요)
null 처리는 어떻게 할까요?
// Example
// ref: https://devblogs.microsoft.com/dotnet/customizing-dotnet-maui-controls/
// by Pedro Jesus
if (control.Handler is null || control.Handler.PlatformView is null)
{
// Workaround for when this executes the Handler and PlatformView is null
control.HandlerChanged += OnHandlerChanged;
return;
}