priya_d
priya_d

Reputation: 403

How to support right-to-left in xamarin.forms

How do I support right-to-left direction of pages in xamarin.forms? I have tried different layouts such as RelativeLayout and StackLayout and set its HorizontalOptions to start or end, but it does not swap the element. Anybody have any idea how we can achieve this?

Upvotes: 4

Views: 2061

Answers (2)

Abdullah Tahan
Abdullah Tahan

Reputation: 2129

i have create custom markup extension will help you to make rtl and ltr layout support the extension have these types :

  • GridLength
  • LayoutOption
  • TextAlignment
  • Int
  • String
  • ResourceKey
  • Thickness

EX: if you want to make you label HorizontalOptions rtl when language is arabic and ltr when its english you do it : HorizontalOptions="{UIExtensions:UIDirection Type=LayoutOption, LTR=Start, RTL=End}"

https://gist.github.com/ads90/ff5c69410d2654dcad3ed8d275d7ca20

Upvotes: 0

Steven Thewissen
Steven Thewissen

Reputation: 2981

Xamarin have started (or at least announced) work on internationalisation, including RTL. Currently it is not in yet though. A workaround for this in e.g. ListView is to create multiple list item templates with LTR/RTL directions and use them according to the current UI culture. For other controls your best bet would be to implement a renderer for each control type and change its HorizontalOptions or XAlignment according to the UI culture. You're basically forced to roll your own.

Upvotes: 8

Related Questions