Properties and Fluent Methods
Version:
v9.x
FmgLib.MauiMarkup
provides a convenient way to set properties for UI elements by matching properties with fluent helper methods. This makes it easier and more readable to define the interface of your application.
Here is an example of using fluent methods to set properties on a Label
:
new Label()
.Text("This is a test")
.Padding(20)
.FontSize(30)
.Center())
FmgLib.MauiMarkup
also provides a way to set property values based on device idiom, platform, or app theme. Here is an example of setting the font size and text color of a Label
based on the current device or theme:
new Label()
.Text("Hello")
.FontSize(e => e.OnDesktop(80).OnPhone(30).Default(50))
.TextColor(e => e.OnLight(Colors.Black).OnDark(Colors.Teal))