I am just getting into .NET and MAUI.
As the question states, I am trying to add a a Icon Button to the ToolBar that can be clicked.
At this moment i have a ToolbarItem with text that can be clicked.
I have also a Icon. For icons, the ToolbarItem class comes with an IconImageSource property, which is of type ImageSource. This means that we can also use a FontImageSource to provide the icon for the button based on a custom font.
I have two problems with the Icon Button.
First: I am not able to change the Size. It does not matter which value i put into the Size the Icon does not change.
Second: Is it possible to introduce the Clicked event like in a Button or ToolbarItem?
Thanks in advance for some help.
Follows the xaml code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Second Page"
Clicked="GotoSecondPage" />
<ToolbarItem >
<ToolbarItem.IconImageSource>
<FontImageSource FontFamily="MaterialIconsOutlined-Regular"
Glyph=""
Color="Black"
Size="120" />
</ToolbarItem.IconImageSource>
</ToolbarItem>
</ContentPage.ToolbarItems>
<Shell.TitleView>
<HorizontalStackLayout VerticalOptions="Fill">
<Label Text="Welcome to MAUI"
FontFamily="Strande2"
TextColor="White"
VerticalTextAlignment="Center"
VerticalOptions="Center"
HeightRequest="50"
FontSize="Medium" />
</HorizontalStackLayout>
</Shell.TitleView>
<ScrollView>
<VerticalStackLayout Padding="30,0"
Spacing="15">
<Label Text="HOME PAGE"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Image Source="dotnet_bot.png"
HeightRequest="130"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Button x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
<Button x:Name="GoToPageTwoButton"
Text="Go to Page Two"
Clicked="GotoSecondPage"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>