Search This Blog

Wednesday, June 24, 2015

How to enable a right to left (RTL) layout in XAF WinForms and ASP.NET apps?

Starting with v15.1, certain WinForms controls support the right to left mode:

An XAF WinForms application is a regular .NET WinForms app that uses DevExpress WinForms controls. Thus, RTL will automatically work for supported controls in XAF. To enable this mode in an XAF WinForms application, handle the XafApplication.CustomizeTemplate event in Program.xx (or override the corresponding virtual method in the WinApplication.xx file) and set the corresponding System.Windows.Forms.Form object properties. You can also additionally override the CreateModelEditorForm method.

namespace YourSolutionName.Win {
    public partial class YourSolutionNameWinApplication : WinApplication {
        public void ApplyRightToLeft(System.Windows.Forms.Form form) {
            if (form != null) {
                form.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
                form.RightToLeftLayout = true;
        protected override void OnCustomizeTemplate(DevExpress.ExpressApp.Templates.IFrameTemplate frameTemplate, string templateContextName) {
            base.OnCustomizeTemplate(frameTemplate, templateContextName);
            ApplyRightToLeft(frameTemplate as System.Windows.Forms.Form);
        protected override System.Windows.Forms.Form CreateModelEditorForm() {
            System.Windows.Forms.Form form = base.CreateModelEditorForm();
            return form;

To enable RTL in XAF ASP.NET WebForms applications, please follow the ASP.NET Controls and MVC Extensions > Common Concepts > Web.config Modifications > Web.config Options > Right to Left Support help article.
It is also possible to enable this mode programmatically via the static DevExpress.Web.ASPxClasses.ASPxWebControl.GlobalRightToLeft property, e.g. per user session as described at S171024. See also: How to enable the rigth to left layout in the View mode for Web Property Editors.

Take special note that so far we have not performed special optimizations or checks at the XAF level for v15.1 and this functionality is automatically derived from our WinForms or ASP.NET components.
We'll plan required R&D in this regard once we confirm real user interest. For now, if you experience any RTL issues when trying the code above only in XAF apps, please report them to us. We'd be happy to discuss their implementation for the future. Also, I recommend you test the newest v15.1.4 build, because it contains a lot of RTL-related fixes in controls.
We'll put any updates on this topic in the How to enable a right to left (RTL) layout in XAF WinForms and ASP.NET apps? article. Your comments on your RTL experience with XAF are also welcome there. Thanks!

No comments:

Post a Comment