Uno.Themes
Uno.Themes copied to clipboard
Have a concise way to use Material for all controls in the app
The current guidance reads:
- (Optional) Set material styles as the default for your whole application. For example, if you wish to use our ToggleSwitch style as your default style, simply set it as an implicit style in your app by adding the following code in your App.xaml
<Style TargetType="ToggleSwitch" BasedOn="{StaticResource MaterialToggleSwitchStyle}"/>
You can do the same for each control! Learn more about implicit styles from the Microsoft documentation here
Manually setting the implicit style for every control is cumbersome and error-prone. Uno Material should provide a single resource dictionary, eg MaterialResourcesDefault
, which sets the implicit styles for all supported controls.
Example usage:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// Set a default palette to make sure all colors used by MaterialResources exist
this.Resources.MergedDictionaries.Add(new Material.MaterialColorPalette());
// Overlap the default colors with the application's colors palette.
// TODO: Replace ms-appx:///Views/ColorPaletteOverride.xaml with your resourceDictionary.
this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("ms-appx:///Views/ColorPaletteOverride.xaml") });
// Add all the material resources. Those resources depend on the colors above, which is why this one must be added last.
this.Resources.MergedDictionaries.Add(new Material.MaterialResources());
// (Optional) Make Material the default style for all controls in the app.
this.Resources.MergedDictionaries.Add(new Material.MaterialResourcesDefault());
[...]
}