I am a bit confused about the CultureInfo properties which we can set at multiple places and how they affect.
1. Language property - This we typically set in Window tag.
2. ConverterCulture - We use it in Binding.
3. StringFormat - This we use to format displayed values, but it also uses CultureInfo parameter.
4. ToString() - We use it to format the value based on passed CultureInfo parameter.
5. System.Threading.Thread.CurrentThread.CurrentCulture value.
Why I have confusion ?
Example #1<TextBox> <TextBox.Text> <Binding Path="." StringFormat="{}{0:C3}"><Binding.Source><sys:Double>12.123</sys:Double></Binding.Source> </Binding> </TextBox.Text></TextBox> System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-IQ");
Output : $12.1
Applying FlowDirection now to above example
Example #2
<TextBox FlowDirection="RightToLeft"><TextBox.Text><Binding Path="." StringFormat="{}{0:C3}"><Binding.Source><sys:Double>12.123</sys:Double></Binding.Source></Binding></TextBox.Text></TextBox> System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-IQ"); Output : All digits converted to arabic except $ sign
Applying ConverterCulture now to above example Example #3 <TextBox FlowDirection="RightToLeft"><TextBox.Text><Binding Path="." StringFormat="{}{0:C3}" ConverterCulture="ar-IQ"><Binding.Source><sys:Double>12.123</sys:Double></Binding.Source></Binding></TextBox.Text></TextBox> System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-IQ"); Note : Keeping both the cultures same. Output : Everything converted including digits + currencysymbol.
Keeping example simplest : Example #4 <TextBox><TextBox.Text><Binding Path="."><Binding.Source><sys:Double>12.123</sys:Double></Binding.Source></Binding></TextBox.Text></TextBox> System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-IQ"); Output : Nothing happens But if we apply FlowDirection=RightToLeft to above , all digits changes.
Why this confused behavior ? Can anyone please explain all examples one by one please.
Anjum S Khan Admin/Analyst Blog.TrackNifty.com