-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data-bound value not adjusted to fall into range for NumberBox #2776
Comments
If the suggested behaviour would be preferred, I would be happy to try to implement this fix :-) . |
@teaP fyi |
@SavoySchuler FYI |
@MartinZikmund This does seem like a bug, if you'd like to contribute the fix that would be awesome! |
@MartinZikmund Would you still like to look into this, or would you be fine with somebody else tackling this? |
@chingucoding Oh, I didn't notice the original response. I will be happy to do this (if it is not a time critical issue right now) |
Right, yes. I don't think it's that time critical. If you need help with setting up the repro or getting started, feel free to ask! |
I don't think its time critical I think there was a mistaken double negative. @MartinZikmund go for it, looking foreword to the PR. |
Oh right, yes there a negation to much in there, you are right @StephenLPeters ! |
I have looked into the issue and it seems this might be a problem with how
I am not sure there is a way to work around this other than making some fix to how |
Interesting, @MikeHillberg and/or @chrisglein do you have more incites on this behavior? |
@StephenLPeters @ranjeshj Given that this seems like an issue with binding, does this need to wait until WinUI 3? |
I think I got this but in reverse. NumberBox Config: <muxc:NumberBox x:Name="MinuteNumberBox"
Value="{Binding Minutes, Mode=TwoWay}"
SpinButtonPlacementMode="Inline"
SmallChange="15"
LargeChange="15"
Minimum="-15"
Maximum="60"
/> ViewModel Property (using MVVM Community Toolkit): private double _minutes;
public double Minutes
{
get { return _minutes; }
set
{
if (value == 60)
{
value = 0;
}
if (value == -15)
{
value = 45;
}
SetProperty(ref _minutes, value);
}
} When I hit Min/Max the Property is updated (e.x. 60 becomes 0) but the change is not propagated to the view. RelayCommand _add15Command;
public RelayCommand Add15Command
{
get
{
return _add15Command ??=
new RelayCommand(
() => Minutes += 15
); ;
}
} |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Describe the bug
When
NumberBox
has aMinimum
/Maximum
range set and the data-boundValue
does not fall within this range, one of the boundary values is displayed in the control, but the boundary value is not propagated to the view model.Steps to reproduce the bug
XAML:
C#:
Now add a button that displays the value of
Test
in debug output. Notice that although number box shows "2", the output value is still 0, unless user modifies the value in any way.Expected behavior
I would expect that the view model value would update accordingly when the "invalid" value is first bound.
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.4.0
Additional context
I have noticed the
Slider
control behaves the same way as well.The text was updated successfully, but these errors were encountered: