Bug 41960 - Stepper changes initially bound value if it is greater than 100
Summary: Stepper changes initially bound value if it is greater than 100
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2016-06-17 19:14 UTC by Tim Wilson
Modified: 2017-06-21 15:30 UTC (History)
6 users (show)

Tags: ac, stepper
Is this bug a regression?: ---
Last known good build:


Attachments
Repro project (289.08 KB, application/x-zip-compressed)
2016-08-12 14:47 UTC, E.Z. Hart [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 41960 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Tim Wilson 2016-06-17 19:14:45 UTC
If a stepper has both the Value and Maximum properties data-bound and the initially bound Value is greater than 100, the stepper automatically changes the Value to 100.

I believe this is caused because Maximum property is most likely defaulted to 100 and the Value property is probably bound before the Maximum property. When the Value is bound, it probably uses the current Maximum of 100 to validate / update the Value.

I worked around the issue by using the following logic:

 // Initialize elements so we can reference the stepper by name.
 InitializeComponent();

 var viewModel = new MyViewModel();

 // Manually bind Maximum
 MyStepper.Maximum = viewModel.Maximum;

 // Allow Xamarin to data-bind as usual
 BindingContext = viewModel;
Comment 1 E.Z. Hart [MSFT] 2016-08-12 14:47:28 UTC
Created attachment 17008 [details]
Repro project
Comment 2 adrianknight89 2016-09-25 02:43:44 UTC
You don't need to create a workaround like above. Simply swap the order value and max are data-bound. You already wrote a similar comment:

// Note that if you swap the order of these two lines, the stepper will have the correct initial value
stepper.SetBinding(Stepper.ValueProperty, "StepperValue");
stepper.SetBinding(Stepper.MaximumProperty, "StepperMax");

I'd be interested to know how this issue could be solved. In my opinion, this should not be treated as a bug.

See https://github.com/xamarin/Xamarin.Forms/pull/377
Comment 3 David Ortinau [MSFT] 2017-06-21 15:30:37 UTC
Putting back to confirmed for Stephane to take a look at this. The offered PR doesn't satisfy the issue.