Skip to main content
All docs
V25.1
  • ApplicationThemeHelper.PreloadAsync(Func<UserControl>) Method

    Asynchronously preloads theme resources for the view specified by the UserControl and allows you to initialize this view before the preload.

    Namespace: DevExpress.Xpf.Core

    Assembly: DevExpress.Xpf.Core.v25.1.dll

    NuGet Package: DevExpress.Wpf.Core

    Declaration

    public static Task PreloadAsync(
        Func<UserControl> createAction
    )

    Parameters

    Name Type Description
    createAction Func<UserControl>

    A function that initializes the preloaded UserControl.

    Returns

    Type Description
    Task

    A task that allows you to asynchronously preload theme resources.

    Remarks

    Note

    The PreloadAsync method allows you to preload lightweight theme resources only. Use the PreloadThemeResourceAsync method instead to asynchronously preload regular theme resources.

    Use this method if the preloaded view is “lightweight” and you populate it with controls at runtime or based on a parameter.

    The following code sample calls the MyControl.Populate() method and asynchronously preloads resources for the MyControl after the method is executed:

    using DevExpress.Xpf.Core;
    using System.Windows;
    
    public partial class App : Application {
        static App() {
            CompatibilitySettings.UseLightweightThemes = true;
        }
        protected override async void OnStartup(StartupEventArgs e) {
            base.OnStartup(e);
            await ApplicationThemeHelper.PreloadAsync(() => new MyControl().Populate());
        }
    }
    

    Refer to the following help topic for more information: Preload Theme Resources.

    See Also