Forum Visual Studio


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Strange right 'margin' for DatePicker rendered for UWP

AlessandroMoscatelliAlessandroMoscatelli USMember
edited March 2016 in Visual Studio

Hi Everybody

DatePicker component is the only one which is not rendered correctly ...

I attached a screenshot.

Thank you


<Frame VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
  <StackLayout Orientation="Vertical">
      HorizontalOptions = "Center"
      VerticalOptions = "Center">
    <Editor VerticalOptions="FillAndExpand">


    <ProgressBar x:Name="progress">

    <SearchBar x:Name="search" Placeholder="Ricerca">


    <Stepper x:Name="stepper">





  • The problem is related only to UWP, Android works correctly.

  • JeffDalbyJeffDalby USUniversity ✭✭

    I've got the same issue. Looks like UWP ignores the format string as well.

  • Thibault_VellicusThibault_Vellicus CHUniversity ✭✭

    Same problem here with DatePicker AND TimePicker...
    Really boring :-(

    It seems that the control is trying to take the full width when displaying the selected date.
    I've tried to set the WidthRequest, but the date stays truncated.

    For me, it's a Xamarin bug with UWP (no problem on iOS and Android)

  • DevelopersISEDDevelopersISED USMember ✭✭

    Some problem here, maybe someone should file a bug on Xamarin Bugzilla

  • Thibault_VellicusThibault_Vellicus CHUniversity ✭✭
    edited June 2016

    Ok... I think I figure it out...
    The good new is that it is not a Xamarin bug.
    The bad news is that I reproduce exactly the same problem with the Universal Windows native code (I put my controls into a Canvas).

    Unbelievable but with the native Microsoft DatePicker and TimePicker: I have to set the MinWidth property in order to fix the width of my control!!! Setting Width or MaxWidth doesn't work!!!!

    Ok now, trying to use the MinWidthRequest from Xamarin component => doesn't work.
    As usual I write a custom Renderer and it works!!!!

    My code:
    [assembly: ExportRenderer(typeof(Xamarin.Forms.TimePicker), typeof(MyTimePickerRenderer))] [assembly: ExportRenderer(typeof(Xamarin.Forms.DatePicker), typeof(MyDatePickerRenderer))] namespace Observo.Client.Win.CustomRenderer { public class MyDatePickerRenderer : ViewRenderer<Xamarin.Forms.DatePicker, Windows.UI.Xaml.Controls.DatePicker> { protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (e.NewElement != null) { SetNativeControl(new Windows.UI.Xaml.Controls.DatePicker { MinWidth = 70 }); } } } public class MyTimePickerRenderer : ViewRenderer<Xamarin.Forms.TimePicker, Windows.UI.Xaml.Controls.TimePicker> { protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.TimePicker> e) { base.OnElementChanged(e); if (e.NewElement != null) { SetNativeControl(new Windows.UI.Xaml.Controls.TimePicker { MinWidth = 70 }); } } } }

    In attachment the result...

    Now I have to improve my custom renderer code with a binding instead of this hard-coded width value.

Sign In or Register to comment.