Skip to content

Commit

Permalink
Don't use loaded/unloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Jul 20, 2023
1 parent 83398c3 commit 8a946c3
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/Controls/src/Core/FlyoutPage/FlyoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ static object GetDefaultValue(BindableObject bindable)
public FlyoutPage()
{
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<FlyoutPage>>(() => new PlatformConfigurationRegistry<FlyoutPage>(this));

this.Loaded += OnLoaded;
this.Unloaded += OnUnloaded;
(this as IControlsVisualElement).WindowChanged += OnWindowChanged;
this.SizeChanged += OnSizeChanged;
}

readonly Lazy<PlatformConfigurationRegistry<FlyoutPage>> _platformConfigurationRegistry;
Expand All @@ -319,15 +318,26 @@ public FlyoutPage()
return _platformConfigurationRegistry.Value.On<T>();
}

void OnUnloaded(object sender, EventArgs e)
void OnSizeChanged(object sender, EventArgs e)
{
DeviceDisplay.MainDisplayInfoChanged -= OnMainDisplayInfoChanged;
if (Handler is not null)
{
Handler?.UpdateValue(nameof(FlyoutBehavior));
SizeChanged -= OnSizeChanged;
}
}

void OnLoaded(object sender, EventArgs e)
void OnWindowChanged(object sender, EventArgs e)
{
DeviceDisplay.MainDisplayInfoChanged += OnMainDisplayInfoChanged;
Handler?.UpdateValue(nameof(FlyoutBehavior));
if (Window is null)
{
this.SizeChanged += OnSizeChanged;
DeviceDisplay.MainDisplayInfoChanged -= OnMainDisplayInfoChanged;
}
else
{
DeviceDisplay.MainDisplayInfoChanged += OnMainDisplayInfoChanged;
}
}

void OnMainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
Expand Down

0 comments on commit 8a946c3

Please sign in to comment.