Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: Binding of Percentage values for NumericUpDown [21973]

$
0
0
Hi,

A recent change to the Extended WPF Toolkit (I think in version 2.5) has changed how NumericUpDown controls bind to underlying values when a FormatString value of "P" (percentage) is used.

Attached is a zip file containing two screen shots and a spike project showing that, when you bind a DoubleUpDown (derived from NumericUpDown) to a double value representing a percentage (i.e. 0.0 -> 1.0) it correctly shows the value formatted as a percentage (i.e. 0.33 is displayed as 33 %). However, when you enter a value of 33 in the "DoubleUpDown bound to value with FormatString=P" control, it writes a value of 33 to the bound property and displays a value of 3,300 %.

This did not happen in previous versions of the toolkit and simply can't be right (it has seriously confused all my users).
Comments: ** Comment from web user: BoucherS **

Hi,

v2.8 is the next release for the "Plus users"....could be in a month or so.
v2.6 is the next release for "Community users".

"Plus users" are always 2 versions ahead.

Here's a temporary fix (since it was working in earlier versions):
in file
-Xceed.Wpf.Toolkit/NumericUpDown/Implementation/CommonNumericUpDown.cs
a) Remove method "ContainsLetterForPercent"
b) Add the following method :
```
private bool IsPercent( string stringToTest )
{
int PIndex = stringToTest.IndexOf( "P" );
if( PIndex >= 0 )
{
bool isText = (stringToTest.Substring( 0, PIndex ).Contains( "'" )
&& stringToTest.Substring( PIndex, FormatString.Length - PIndex ).Contains( "'" ));

return !isText;
}
return false;
}
```
c) Replace the calls to "ContainsLetterForPercent" for calls to "IsPercent".


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>