The below code properly work on Android but it' throws null exception on iOS.On ios first select it's not loading the page and when you select another item on list after the first selection it will load that page. My code is given below.
menuPage.Menu.ItemSelected += (sender, e) =>
{
NavigateTo(e.SelectedItem as Drawer_MenuItem,sender);
};
private void NavigateTo(Drawer_MenuItem menu,Object se)
{
Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);
this.Detail = new NavigationPage(displayPage);
IsPresented = false;
if (menu != null)
{
if (menuPage.Menu.SelectedItem != null)
{
((ListView)se).SelectedItem = null;
}
}
}
UPDATE :
I have found the bug but did't get any solution. The bug is in custom render which is used for custom stack layout and entry. If I remove custom render It is working fine.Otherwise it is having the same problem.
Please help me with this problem using custom render.
Code for custom render:
[assembly:ExportRenderer(typeof(Custom_StackLayout),typeof(CustomStackLayoutRenderer))]
namespace LIVI.iOS.Renderers
{
public class CustomStackLayoutRenderer : VisualElementRenderer<Custom_StackLayout>
{
protected override void OnElementChanged(ElementChangedEventArgs<Custom_StackLayout> e)
{
base.OnElementChanged(e);
if (e.NewElement.ClassId == "noborder")
{
Layer.CornerRadius = 15;
Layer.BorderColor = Color.FromHex("#e57593").ToCGColor();
Layer.BorderWidth = 1;
Layer.MasksToBounds = true;
}
else if(e.NewElement.ClassId== "noborderDriverInfo")
{
Layer.CornerRadius = 15;
Layer.MasksToBounds = true;
}
else if(e.NewElement.ClassId== "btn_viewProfile")
{
Layer.CornerRadius = 15;
Layer.BorderColor = Color.White.ToCGColor();
Layer.BorderWidth = 1;
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "filledStackLayout")
{
Layer.CornerRadius = 5;
Layer.BorderColor = Color.Transparent.ToCGColor();
Layer.BorderWidth = 0;
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "imgborder")
{
Layer.CornerRadius = 10;
Layer.BorderWidth = 2;
Layer.BorderColor = Color.FromHex("#FFC600").ToCGColor();
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "conDriverMob")
{
Layer.CornerRadius = 10;
Layer.BorderWidth = 2;
Layer.BorderColor = Color.FromHex("#e9eaeb").ToCGColor();
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "imgBtn")
{
Layer.CornerRadius = 10;
Layer.BorderWidth = 3;
Layer.BorderColor = Color.White.ToCGColor();
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "cellWrapper")
{
Layer.CornerRadius = 1;
Layer.BorderWidth = 2;
Layer.BorderColor = Color.FromHex("#e9eaeb").ToCGColor();
Layer.MasksToBounds = true;
}
else if (e.NewElement.ClassId == "sqBorder")
{
Layer.BorderWidth = 2;
Layer.BorderColor = Color.FromHex("#e9eaeb").ToCGColor();
Layer.MasksToBounds = true;
}
else
{
Layer.CornerRadius = 15;
Layer.BorderWidth = 2;
Layer.BorderColor = Color.White.ToCGColor();
Layer.MasksToBounds = true;
}
}
}
}