title | page_title | description | position | tags | slug |
---|---|---|---|---|---|
Content Configuration |
.NET MAUI ToggleButton Documentation - Content Alignment |
Learn how to define, position, and format the content of the Telerik ToggleButton for .NET MAUI. |
3 |
.net maui, telerik toggle button for .net maui, ui for .net maui, toggle button, microsoft .net maui |
togglebutton-configuration |
The purpose of this help article is to show you the main configuration options of the control.
Define the content inside the ToggleButton by setting the Content
property (object
) or ContentTemplate
(DataTemplate
) property.
The Content
is responsible for the actual content displayed in the button. It can be set to string
, View
, complex object, etc.
Here are the scenarios for the visualization of Content
or ContentTemplate
inside the RadToggleButton
:
-
If
ContentTemplate
is set, theView
returned from theContentTemplate
.CreateView()
is displayed inside theRadToggleButton.ControlTemplate
, havingContent
as itsBindingContext
. -
If
ContentTemplate
isDataTemplateSelector
, first theDataTemplate
is selected and then aView
is created from the chosen template usingContent
as itsBindingContext
. -
If
Content
is set to aView
andContentTemplate
isn't set, theView
is displayed inside theRadToggleButton.ControlTemplate
. -
If
Content
is set to astring
andContentTemplate
isn't set, aLabel
is displayed inside theRadToggleButton.ControlTemplate
. -
If
Content
is set to anobject
andContentTemplate
isn't set, theToString()
of theobject
is used and converted toLabel
inside theRadToggleButton.ControlTemplate
.
Setting Content to String
Setting ContentTemplate
For a runnable example demonstrating the ToggleButton ContentTemplate, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to the ToggleButton > Features category.
Use the following properties to align the text in the button when Content
is string
and ContentTemplate
is not set.
HorizontalTextAlignment
(Microsoft.Maui.TextAlignment
)—Specifies the horizontal alignment of theLabel.Text
.VerticalTextAlignment
(Microsoft.Maui.TextAlignment
)—Specifies the vertical alignment of theLabel.Text
.
Use the TextDecorations
(enum of type Microsoft.Maui.TextDecorations
) property to specify the text decorations of the Label
created when Content
is string
and ContentTemplate
is not set.
The following properties specify the font options that apply to the content when Content
is string
and ContentTemplate
is not set.
FontFamily
(string
)—Specifies the font family of theLabel.Text
.FontSize
(double
)—Specifies the font size in pixels of theLabel.Text
.FontAttributes
(Microsoft.Maui.Controls.FontAttributes
)—Specifies the font attributes of theLabel.Text
.
- [Toggle State]({%slug togglebutton-toggle-states%})
- [Set Visual States]({%slug togglebutton-visual-states%})
- [Events]({%slug togglebutton-events%})
- [Execute Command]({%slug togglebutton-command%})
- [Style the ToggleButton]({%slug togglebutton-styling%})