-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Slider clamps bound value to default min max value when removed from visual tree #11870
Comments
Here is a falling test for this [Fact]
public void ChangingDataContextShouldNotChangeOldDataContext()
{
var viewModel = new RangeTestViewModel()
{
Minimum = -5000,
Maximum = 5000,
Value = 4000
};
var target = new TestRange
{
[!RangeBase.MinimumProperty] = new Binding(nameof(viewModel.Minimum)),
[!RangeBase.MaximumProperty] = new Binding(nameof(viewModel.Maximum)),
[!RangeBase.MaximumProperty] = new Binding(nameof(viewModel.Value)),
};
var root = new TestRoot(target);
target.DataContext = viewModel;
target.DataContext = null;
Assert.Equal(4000, target.Value);
Assert.Equal(-5000, target.Minimum);
Assert.Equal(5000, target.Maximum);
}
private class RangeTestViewModel
{
public double Minimum { get; set; }
public double Maximum { get; set; }
public double Value { get; set; }
} |
Your test seems to set Maximum Property twice rather than value. |
This bug also happens when binding to a nested viewmodel (or any observable object/property) that is set later. <AnyRangeBase Value="{Binding NestedViewModel.Value}"/>
|
After some fiddling it was an issue with my XAML, where I set Value first before the range. Seems like what I did also fixed the issue without using this PR. I'd say my issue was a PEBKAC and is different from this one. |
This bug is driving me mad, i get a "100" set value in when, for example, deselecting an element where a Slider was present. |
Describe the bug
A slider or any RangeBase control with Value, Minimum and Maximum bound writes a value back to the binding clamped to the default (0 ,100) rather than the bound min max.
To Reproduce
Steps to reproduce the behavior:
Run the repro and click flip twice, The slider will change value when it should not
RangeBaseRepro.zip
Expected behavior
The view model should maintain the requested value.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: