Microsoft KB Archive/937131

= Numbers that are immediately followed by special characters, such as &quot;100%,&quot; may not appear correctly when you create a WPF application in the .NET Framework 3.0 =

Article ID: 937131

Article Last Modified on 6/19/2007

-

APPLIES TO


 * Microsoft .NET Framework 3.0

-





SYMPTOMS
Consider the following scenario:  You create a Windows Presentation Foundation (WPF) application in the Microsoft .NET Framework 3.0. The language that you use to create this application flows from right to left. Hebrew and Arabic are examples of such languages. In the application, you use a number that is immediately followed by one of the following special characters:  # % ° ±</li> $</li></ul>

For example, you use &quot;100%.&quot;

Or, the program enables user input, and a user enters a number that is immediately followed by a special character.

Note This problem may also occur when other special characters are used, such as some currency symbols.</li></ul>

In this scenario, a number that is immediately followed by a special character may not appear correctly. For example, &quot;100%&quot; may appear as &quot;%100.&quot;

<div class="cause_section">

CAUSE
This problem may occur because WPF incorrectly formats numbers that must flow from left to right when those numbers appear in text that flows from right to left.

<div class="workaround_section">

WORKAROUND
To work around this problem, use one of the following methods.

Note Future updates to WPF will fix this problem. Therefore, we strongly recommend that you use only the method that applies to your specific situation.

Method 1: Add a Unicode right-to-left marker before the number
If the number that has the special character appears the static text of the application, add a Unicode right-to-left marker before the number.

The following is an example of Extensible Application Markup Language (XAML) code that adds a Unicode right-to-left marker before the number: <StackPanel FlowDirection=&quot;RightToLeft&quot;> <TextBlock> &#x200f;100% </TextBlock> </StackPanel>

Method 2: Set the FlowDirection property to &quot;LeftToRight,&quot; and set the TextAlignment property to &quot;Right&quot;
If the number that has the special character is introduced by user input, set the FlowDirection property to &quot;LeftToRight.&quot; Also, set the TextAlignment property to &quot;Right.&quot;

The following is an example of XAML code that sets these properties correctly: <StackPanel FlowDirection=&quot;RightToLeft&quot;> <TextBlock FlowDirection=&quot;LeftToRight&quot; TextAlignment=&quot;Right&quot;> 100% </TextBlock> </StackPanel>

<div class="moreinformation_section">

Steps to reproduce the problem
<ol> Start Microsoft Visual Studio 2005.</li> On the File menu, click New Project.</li> In the New Project dialog box, click Visual Basic under Project Types.</li> Under Visual Studio Installed Templates, click Windows Applications (WPF).</li> In the Name box, type the name of the application, and then click OK.</li> On the View menu, click Toolbox.</li> Add a StackPanel control to the form.</li>  On the Window1.xaml tab, locate the following code: <StackPanel Height=&quot;50&quot; Margin=&quot;136,58,106,0&quot; MinHeight=&quot;50&quot; MinWidth=&quot;50&quot; Name=&quot;StackPanel1&quot; VerticalAlignment=&quot;Top&quot; /> </li>  Replace this code with the following: <StackPanel FlowDirection=&quot;RightToLeft&quot;> <TextBlock> 100% </TextBlock> </StackPanel> </li> On the Debug menu, click Start Debugging.</li></ol>

Keywords: kbtshoot kbprb KB937131

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.