Back to Devexpress

WindowsFormsSettings.TouchScaleFactor Property

windowsforms-devexpress-dot-xtraeditors-dot-windowsformssettings-41df96c9.md

latest6.5 KB
Original Source

WindowsFormsSettings.TouchScaleFactor Property

Gets or sets a scale factor used to calculate the size of controls and distance between their elements in touch UI mode. This is a static (Shared in VB.NET) property.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
[DefaultValue(2F)]
public static float TouchScaleFactor { get; set; }
vb
<DefaultValue(2F)>
Public Shared Property TouchScaleFactor As Single

Property Value

TypeDefaultDescription
Single2

A scale factor used to calculate the size of controls and distance between their elements in touch UI mode.

|

Remarks

In touch UI mode, controls automatically increase their size and the distance between some of their elements. The following images show a Ribbon Control painted when touch UI mode is disabled and enabled, respectively.

Project Settings

Use the DevExpress Project Settings window to enable touch mode and specify the scale factor. Right-click the project in the Solution Explorer window, then click DevExpress Project Settings.

In the Application UI section, specify UI mode and the scale factor.

Settings specified in the DevExpress Project Settings window are applied at design time and runtime.

Application Configuration File

You can also modify the project’s App.config file as shown below to enable touch mode and specify the scale factor. Note that you should reopen the project to apply the changes.

xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral">
      <section name="DevExpress.LookAndFeel.Design.AppSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral" requirePermission="false"/>
    </sectionGroup>
  </configSections>
  <applicationSettings>
    <DevExpress.LookAndFeel.Design.AppSettings>
      <setting name="TouchUI" serializeAs="String">
        <value>True</value>
      </setting>
      <setting name="TouchScaleFactor" serializeAs="String">
        <value>1.5</value>
      </setting>
    </DevExpress.LookAndFeel.Design.AppSettings>
  </applicationSettings>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
</configuration>

Settings in the application configuration file are only applied at design time. To apply these settings at runtime, call the LoadApplicationSettings() method before the main application form is initialized, or specify settings in code.

Note

We recommend that you use the DevExpress Project Settings window to specify UI mode and the scale factor.

Specify UI Mode in Code

You can also use the TouchUIMode and TouchScaleFactor properties to enable touch mode and the scale factor in code. Specify these settings before the main application form is initialized.

csharp
using DevExpress;

static class Program {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() {
        WindowsFormsSettings.TouchUIMode = LookAndFeel.TouchUIMode.True;
        WindowsFormsSettings.TouchScaleFactor = 2;
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
vb
Imports DevExpress

Friend Module Program
    ''' <summary>
    ''' The main entry point for the application.
    ''' </summary>
    <STAThread>
    Private Sub Main()
        WindowsFormsSettings.TouchUIMode = LookAndFeel.TouchUIMode.True
        WindowsFormsSettings.TouchScaleFactor = 2
        Call Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Call Application.Run(New Form1())
    End Sub
End Module

Note

If you specify UI mode and the scale factor in code, these settings are only applied at runtime. To apply touch UI mode at design time, use DevExpress Project Settings.

Specify UI Mode in Code for a Specific Form

Use a form’s TouchUIMode and TouchScaleFactor options to specify the form’s UI mode and scale factor. To access these options, use the form’s LookAndFeel property. These options are in effect for XtraForm and TabForm objects and their descendants, except for RibbonForm objects. A form’s options override the global TouchUIMode and TouchScaleFactor options.

See Also

TouchUIMode

WindowsFormsSettings Class

WindowsFormsSettings Members

DevExpress.XtraEditors Namespace