Hi Team,
We at Syncfusion develop data visualization controls for Xamarin, Please refer the below link for a description about us.
UserGuide: https://help.syncfusion.com/xamarin/sfdatagrid/overview
FeatureTour: https://www.syncfusion.com/products/xamarin.
This is to bring to your notice, a possible bug in the Xamarin.Forms.UWP renderer creation.
In the attached (SimpleSample.zip), i have a simple scroll view, with a grid layout as its content. In the聽button click(Create Renderer) i pass聽the scrollview and the control flow to the UWP renderer using a DependencyService, where, i use the Platform.CreateRenderer() to create a native renderer first.
Then in the next button click(Start native view conversion), i again pass the scrollview and the flow to the UWP renderer using a DependencyService where i first check, whether the given forms view ( scroll view) has a native renderer using the code.
Platform.GetRenderer(scrollview)
Then if a renderer exists, i dispose the renderer and set null value to the renderer property of the scroll view. Refer the below code.
var renderer = Platform.GetRenderer(formsView);
聽聽聽聽聽聽聽聽聽聽聽聽if (renderer != null)
聽聽聽聽聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽renderer.Dispose();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Platform.SetRenderer(formsView, null);
聽聽聽聽聽聽聽聽聽聽聽聽}
Now i again create a new native renderer for the same forms view ( scroll view) . At this point i get the below exception.
To investigate further and to get more details of the crash i cloned the ScrollViewRenderer.cs of UWP from the below link聽https://github.com/xamarin/Xamarin.Forms/blob/bd31e1e9fc8b2f9ad94cc99e0c7ab058174821f3/Xamarin.Forms.Platform.UAP/VisualElementExtensions.cs
and registered this custom renderer for ScrollView and was able to zero down the root cause,聽
In the UpdateContent method of the UWP ScrollViewRenderer, in line number 145, you are trying to set content to the native UWP's scroll view. Here renderer.ContainerElement is of type page renderer. May be this could be the issue.聽
Upon adding try catch for the same, was able to get the below error as exception message.
The parameter is incorrect. SliderStyle.xaml is not a valid absolute URI
You could find this CustomRenderer in the name of MyScrollViewRenderer in the UWP project. Ensure to un comment the renderer registration line above the namespace to trigger my custom renderer.
In the other attached sample, we would have installed the SfPopupLayout nugets, where the actual issue was reproduced. You can have a look at that too for reference.
CustomRenderer(ScrollViewRenderer) should be converted to native view with out any exception
While converting CustomRenderer(ScrollViewRenderer) getting exception
SimpleSample => http://www.syncfusion.com/downloads/support/directtrac/general/ze/SimpleSample-891056696
SfPopupLayoutSample => http://www.syncfusion.com/downloads/support/directtrac/general/ze/SfPopupLayoutSample-1292317045
+1
+1 Also, I might be biased though because I'm pretty sure this is related to a bug I filed with SyncFusion :)
I also have this issue and this prevents my team from upgrading XF 3.4 to 3.6 together with newest syncfusion version.
@nschoenberg this work around might help you. I wrote a helper that just on UWP removes any of the templates, then shows the popup and then adds the templates back. Works well, just note, if you try that on iOS or Android it won't work, so make sure to only open the popup without templates on UWP
`
private static void InternalSafeShow(SfPopupLayout popup, Action
{
switch (Xamarin.Forms.Device.RuntimePlatform)
{
case Xamarin.Forms.Device.UWP:
var contentTemplate = popup.PopupView.ContentTemplate;
var headerTemplate = popup.PopupView.HeaderTemplate;
popup.PopupView.HeaderTemplate = null;
popup.PopupView.ContentTemplate = null;
showAction(popup);
popup.PopupView.HeaderTemplate = headerTemplate;
popup.PopupView.ContentTemplate = contentTemplate;
return;
default:
showAction(popup);
return;
}
}
`
Hi @samhouts, Any update on this?
Hi @samhouts
Can you please let us know whether this issue has fixed in last stable Forms version 4.1.0.555618 or not? If not let us know when this fix will be included ?
@DeepikaBalaSubramaniyan It is not yet merged. I expect it will be merged this week and released in a service release shortly thereafter. Thank you for your patience.
closed by #6557
Most helpful comment
@nschoenberg this work around might help you. I wrote a helper that just on UWP removes any of the templates, then shows the popup and then adds the templates back. Works well, just note, if you try that on iOS or Android it won't work, so make sure to only open the popup without templates on UWP showAction)
`
private static void InternalSafeShow(SfPopupLayout popup, Action
{
switch (Xamarin.Forms.Device.RuntimePlatform)
{
case Xamarin.Forms.Device.UWP:
var contentTemplate = popup.PopupView.ContentTemplate;
var headerTemplate = popup.PopupView.HeaderTemplate;
`