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

Fixing Popup Uwp Release Compilation Crash #1303

Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e2e1dad
Fixing Popup Uwp Release Compilation Crash
inforithmics May 16, 2021
bd9a2c2
Update NavigationExtensions.uwp.cs
inforithmics May 17, 2021
d2d7895
revert change
inforithmics May 17, 2021
06b05cd
Set Renderer in Create Renderer
inforithmics May 17, 2021
eaf8823
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Extensions/Navig…
AndreiMisiukevich May 18, 2021
4360ce5
Merge branch 'main' into FixPopupUwpReleaseCompilation
AndreiMisiukevich May 18, 2021
27d9726
Merge branch 'main' into FixPopupUwpReleaseCompilation
jsuarezruiz May 25, 2021
353a6a0
Merge branch 'main' into FixPopupUwpReleaseCompilation
pictos Jun 16, 2021
5eb6322
Merge branch 'main' into FixPopupUwpReleaseCompilation
jsuarezruiz Jul 1, 2021
61c46dd
Merge branch 'main' into FixPopupUwpReleaseCompilation
TheCodeTraveler Jul 1, 2021
70eab3b
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Jul 16, 2021
787e379
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 7, 2021
24d7bca
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 12, 2021
377d3e2
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 17, 2021
a03aded
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 19, 2021
8eb17c9
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 27, 2021
0b64b77
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Aug 31, 2021
ccb5f0c
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Sep 28, 2021
882fd98
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Oct 14, 2021
f4f0212
fixed build
inforithmics Oct 25, 2021
c547946
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Oct 25, 2021
15ce898
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Nov 1, 2021
dbe8e0c
Merge branch 'main' into FixPopupUwpReleaseCompilation
inforithmics Nov 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.CommunityToolkit.UI.Views;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.UWP;

namespace Xamarin.CommunityToolkit.Extensions
Expand All @@ -11,7 +13,7 @@ public static partial class NavigationExtensions
static void PlatformShowPopup(BasePopup popup)
{
popup.Parent = GetCurrentPage(Application.Current.MainPage);
Platform.CreateRenderer(popup);
CreateRenderer(popup);

// https://github.com/xamarin/Xamarin.Forms/blob/0c95d0976cc089fe72476fb037851a64987de83c/Xamarin.Forms.Platform.iOS/PageExtensions.cs#L44
Page GetCurrentPage(Page currentPage)
Expand All @@ -38,5 +40,22 @@ Page GetCurrentPage(Page currentPage)
PlatformShowPopup(popup);
return popup.Result;
}

/// <summary>
/// ATTENTION: Create the Renderer for UWP Don't use the one Provided by Xamarin.Forms, Causes a crash in Native Compiled Code
/// 1. DefaultRenderer is PopupRenderer instead of DefaultRenderer()
/// 2. No Invalid Cast Exceptions in UWP Native when the Xamarin Forms Renderer Functions is used.
/// </summary>
/// <param name="element">Element for getting the renderer</param>
// https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.UAP/Platform.cs
static void CreateRenderer(VisualElement element)
{
if (element == null)
throw new ArgumentNullException(nameof(element));

var renderer = Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element) ?? new PopupRenderer();

renderer.SetElement(element);
}
}
}
}