Skip to content

Restyling Through XML

Roman Shapiro edited this page Sep 19, 2019 · 41 revisions

Overview

Method Stylesheet.LoadFromSource loads a stylesheet.

It has following signature:

    public static Stylesheet LoadFromSource(string stylesheetXml,
        Func<string, IRenderable> textureGetter,
        Func<string, SpriteFont> fontGetter);

stylesheetXml is string, containing stylesheet XML data. Following link is example of such data(default Myra UI stylesheet): https://github.com/rds1983/Myra/blob/master/src/Myra/Resources/default_ui_skin.xml

textureGetter and fontGetter are methods, returning correspondengly images and fonts by their ids.

Following code sets loaded stylesheet as current:

    Stylesheet.Current = stylesheet;

Note. The default style is being applied to the widget in the moment of the creation. Therefore all changes to Stylesheet.Current should be done before the UI is created.

CustomUIStylesheet Sample

Clone this wiki locally