Search code examples
iosxamarinmaster-pagesuidatepicker

Xamarin MasterDetail page and UIDatePicker doesn't show


I'm creating empty project and adding master page there. If i add ios UIDatePicker to mainPage everything works, but on MasterDetailPage doesn't, checked element from code on masterPage it is null.

this master detail page

<Grid>

        <ios:UIDatePicker x:Name="dp" />

</Grid>

and this usual main page

<Grid x:Name="content1">
        <ios:UIDatePicker x:Name="dp" />
</Grid>

just change MainPage = new App8.MainPage(); to
MainPage = new App8.MasterDetailPage1(); in app.xaml.cs


Solution

  • found solution, add stacklayout to your xaml page, and folowing code to cs file

     var dt = new UIDatePicker();
     UIView vw = new UIView();
     var fr = vw.Frame;
     fr.Width = 300f;
     fr.Height = 100f;
     vw.Frame = fr;
     dt.Frame = new CGRect (0, 0, vw.Frame.Width,0);
     dt.ClipsToBounds=true;
     vw.AddSubview(dt);
     yourStackLayout.Children.Add(vw);