Method SetScheme
SetScheme(Scheme?)
Sets the scheme for the View, marking it as explicitly set.
public bool SetScheme(Scheme? scheme)
Parameters
scheme
SchemeThe scheme to set, or null to clear the explicit scheme.
Returns
- bool
True if the scheme was set, false if unchanged or cancelled.
Examples
view.SchemeChanging += (sender, args) =>
{
if (args.NewValue is null)
{
args.Handled = true;
Console.WriteLine("Null scheme cancelled.");
}
};
view.SchemeChanged += (sender, args) =>
{
Console.WriteLine($"Scheme changed to {args.NewValue?.Name ?? "none"}.");
};
bool set = view.SetScheme(SchemeManager.GetScheme("Base"));
Remarks
This method uses the Cancellable Work Pattern (CWP) via ChangeProperty<T>(T, T, Func<ValueChangingEventArgs<T>, bool>, EventHandler<ValueChangingEventArgs<T>>?, Action<ValueChangedEventArgs<T>>?, EventHandler<ValueChangedEventArgs<T>>?, out T) to allow customization or cancellation of the scheme change through the OnSettingScheme(ValueChangingEventArgs<Scheme?>) method and SchemeChanging event. The SchemeChanged event is raised after a successful change.
If set to null, HasScheme will be false, and the view will inherit the scheme from its SuperView or fall back to the base scheme.