Describe the bug
If you create a resource for the DoubleToObjectConverter as follows (note that GreaterThan and LessThan are both set):
<wctconverters:DoubleToObjectConverter x:Key="ZeroDoubleToVisibilityConverter"
GreaterThan="-1"
LessThan="1"
TrueValue="<somevalue>"
FalseValue="<somevalue>"
NullValue="<somevalue>" />
If the value is either greater than GreaterThan or less than LessThan the first if statement returns false as expected. However this results in one or the other of the following else if statements returning true which doesn't indicate that the value was not between the GreaterThan and LessThan values.
Regression
No response
Reproducible in sample app?
Steps to reproduce
1. Create an application.
2. Create a resource for a `DoubleToObjectConverter`.
3. In the resource specify values for BOTH `GreaterThan` AND `LessThan`.
4. Use the converter in a property in a xaml file.
Expected behavior
If the value passed to the converter is greater than GreaterThan or less than LessThan the converter should return FalseValue.
Screenshots
No response
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
4.8.09032
Device form factor
Desktop
Nuget packages
CommunityToolkit.WinUI.UI 7.1.2
Microsoft.WindowsAppSDK 1.2.230217.4
Microsoft.Windows.SDK.BuildTools 10.0.22621.755
Additional context
Changing the following code in DoubleToObjectConverter.cs:
if (!double.IsNaN(GreaterThan) && !double.IsNaN(LessThan) && vd > GreaterThan && vd < LessThan)
{
boolValue = true;
}
else if (!double.IsNaN(GreaterThan) && vd > GreaterThan)
{
boolValue = true;
}
else if (!double.IsNaN(LessThan) && vd < LessThan)
{
boolValue = true;
}
To:
if (!double.IsNaN(GreaterThan) && !double.IsNaN(LessThan))
{
if (vd > GreaterThan && vd < LessThan)
{
boolValue = true;
}
}
else if (!double.IsNaN(GreaterThan) && vd > GreaterThan)
{
boolValue = true;
}
else if (!double.IsNaN(LessThan) && vd < LessThan)
{
boolValue = true;
}
}
fixes the issue by isolating the logic for both values being set from the logic for only one value being set.
Describe the bug
If you create a resource for the DoubleToObjectConverter as follows (note that
GreaterThanandLessThanare both set):If the value is either greater than
GreaterThanor less thanLessThanthe firstifstatement returns false as expected. However this results in one or the other of the followingelse ifstatements returning true which doesn't indicate that the value was not between theGreaterThanandLessThanvalues.Regression
No response
Reproducible in sample app?
Steps to reproduce
Expected behavior
If the value passed to the converter is greater than
GreaterThanor less thanLessThanthe converter should returnFalseValue.Screenshots
No response
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
4.8.09032
Device form factor
Desktop
Nuget packages
CommunityToolkit.WinUI.UI 7.1.2
Microsoft.WindowsAppSDK 1.2.230217.4
Microsoft.Windows.SDK.BuildTools 10.0.22621.755
Additional context
Changing the following code in DoubleToObjectConverter.cs:
To:
fixes the issue by isolating the logic for both values being set from the logic for only one value being set.