--- /dev/null
+using System;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 4961, "TimePicker does not remeasure its size when picking a new time that is wider than the previously selected value",
+ PlatformAffected.Android | PlatformAffected.iOS)]
+ public class Issue4961 : TestContentPage
+ {
+ protected override void Init()
+ {
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label
+ {
+ Text = "When changing the Time of the TimePicker the control should be remeasured and its size may change. " +
+ "Set the time to 12:50 AM and check that the text does not get out of the screen."
+ },
+ new TimePicker
+ {
+ Time = TimeSpan.FromHours(1),
+ HorizontalOptions = LayoutOptions.EndAndExpand,
+ VerticalOptions = LayoutOptions.Start
+ }
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
<DependentUpon>Issue1588.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Issue4961.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4629.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4384.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4782.cs" />
void TimePickerDialog.IOnTimeSetListener.OnTimeSet(ATimePicker view, int hourOfDay, int minute)
{
ElementController.SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
-
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
if (Forms.IsLollipopOrNewer)
{
var timeFormat = Is24HourView ? "HH:mm" : Element.Format;
EditText.Text = DateTime.Today.Add(time).ToString(timeFormat);
+ Element.InvalidateMeasureNonVirtual(Internals.InvalidationTrigger.MeasureChanged);
}
void UpdateFont()
{
_picker.Date = new DateTime(1, 1, 1).Add(Element.Time).ToNSDate();
Control.Text = DateTime.Today.Add(Element.Time).ToString(Element.Format);
+ Element.InvalidateMeasureNonVirtual(Internals.InvalidationTrigger.MeasureChanged);
}
}
}
\ No newline at end of file