3

I am trying to set the FlowDirection of all the windows the application will generate to RightToLeft. I tried the following

Window.FlowDirectionProperty.OverrideMetadata(
    typeof(Window),
    new FrameworkPropertyMetadata(CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft
    ? FlowDirection.RightToLeft : FlowDirection.LeftToRight));

I am doing this before I initialize any Window class.

But with this, I get TypeInitializerException whenever I initialize a Window class.

System.TypeInitializationException: The type initializer for 'System.Windows.Window' threw an exception. ---> System.ArgumentException: PropertyMetadata is already registered for type 'Window'.

Any ideas on what I am doing wrong or how I could change my code to get this to work?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
BU.
  • 113
  • 7

1 Answers1

0

Try to set static FlowDirection property to your app

static property Windows::UI::Xaml::FlowDirection FlowDirection{ 
Windows::UI::Xaml::FlowDirection get() ; };

Then call next line in constuctor of application pages:

this->FlowDirection = App::FlowDirection;
Sal00m
  • 2,938
  • 3
  • 22
  • 33
lenka
  • 1