#762 – Set FlowDirection at Runtime Based on CurrentUICulture

The FlowDirection property of a FrameworkElement (including a Window) indicates how child elements of an element should be layed out–left to right (what we are used to in the US), or right to left.

FlowDirection should typically be set to match the text direction of the language being used to render text in your user interface.  If text in your application is in Arabic, the letters will run right to left, so your GUI should also be layed out right to left.

You’ll normally load text resources based on the CurrentUICulture property, which is meant to indicate the target language for your application.  So you should also set the flow direction based on information pointed to by CurrentUICulture.

For example:

        public MainWindow()
        {
            InitializeComponent();

            this.FlowDirection =
                CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ?
                    FlowDirection.RightToLeft :
                    FlowDirection.LeftToRight;
        }

On an English version of Windows, we get:
762-001
And on an Arabic version of Windows, we now get:
762-002

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

2 Responses to #762 – Set FlowDirection at Runtime Based on CurrentUICulture

  1. Pingback: Dew Drop – February 25, 2013 (#1,504) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: