Change Hamburger Menu Icon in .NET MAUI app - maui

How can I change the hamburger menu icon in a .NET MAUI app?
I've updated the style of all my icons and I want to change the hamburger menu icon to a custom PNG.
I tried the following in Styles.xaml but that doesn't seem to be the correct property to edit.
<Style TargetType="FlyoutPage">
<Setter Property="IconImageSource" Value="custom_menu_icon.png" />
</Style>

Solution for FlyoutPage
The Flyout of the FlyoutPage is of type ContentPage and thus the icon should be set there instead:
<ContentPage
IconImageSource="custom_menu_icon.png" />
</ContentPage>
You can also define it in the Styles.xaml and assign the style to the page:
<Style TargetType="ContentPage" x:Key="FlyoutStyle">
<Setter Property="IconImageSource" Value="custom_menu_icon.png" />
</Style>
<ContentPage
Style="{StaticResource FlyoutStyle}" />
</ContentPage>
See also: https://learn.microsoft.com/dotnet/maui/user-interface/pages/flyoutpage?view=net-maui-7.0#create-a-flyoutpage
This assumes that you're using the FlyoutPage and not Shell.
Solution for Shell
In case you're using Shell, you can define the style as follows:
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<!-- skipping existing setters here -->
<Setter Property="Shell.FlyoutIcon" Value="custom_menu_icon.png" />
</Style>
See more: https://learn.microsoft.com/dotnet/maui/fundamentals/shell/flyout?view=net-maui-7.0#flyout-icon

Related

Setting size of editor for chat UI in .NET MAUI app

In my .NET MAUI app, I'm implementing chat feature and want to make sure that the Editor and Button are perfectly located at the bottom of the screen.
I created a Grid for the controls to produce this layout
The problem I'm having is with the Editor width because if I get it to look right on Android, it's not perfect on iOS and vice versa.
Here's how I approached it:
<Grid
RowDefinitions="50"
ColumnDefinitions="*,50"
RowSpacing="0"
ColumnSpacing="5"
HorizontalOptions="StartAndExpand"
Margin="5,5,5,5">
<Editor
Grid.Column="0" />
<Button
Grid.Column="1" />
</Grid>
Other than entering some arbitrary number for WidthRequest for the Editor, how do I set the width for it so that it always takes up all the available space and look like it in the picture?
After setting HorizontalOptions="FillAndExpand" as Jason suggested like below, it looks right on Android and iOS.
<Grid
RowDefinitions="50"
ColumnDefinitions="*,50"
RowSpacing="0"
ColumnSpacing="5"
HorizontalOptions="FillAndExpand"
Margin="5">
<Editor
Grid.Column="0" />
<Button
Grid.Column="1" />
</Grid>

Syncfusion MAUI DataGrid and VerticalStackLayout

I would like to add label above Syncfusion Datagrid but the label is hidden when I run the app in the following page.
See the following repos for complete app.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DataGrid.Views.OrderInfoRepositoryView"
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
xmlns:local="clr-namespace:DataGrid"
Title="Order Info Repository View">
<ContentPage.BindingContext>
<local:OrderInfoRepositoryViewModel x:Name="viewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<VerticalStackLayout Margin="20"
Spacing="10">
<Label Text="OrderInfo"
Margin="10,10,10,10"
TextColor="White"
BackgroundColor="Red"/>
<syncfusion:SfDataGrid x:Name="dataGrid"
ItemsSource="{Binding OrderInfoCollection}">
</syncfusion:SfDataGrid>
</VerticalStackLayout>
</ContentPage.Content>
Did try the following but same result.
<Label Text="OrderInfo"
Margin="10,10,10,10"
TextColor="White"
BackgroundColor="Red"/>
<syncfusion:SfDataGrid x:Name="dataGrid"
ItemsSource="{Binding OrderInfoCollection}">
</syncfusion:SfDataGrid>
</VerticalStackLayout>
Here Android screenshot
Added LineHeight and fontSize. No change
Tested with HeightRequest. No change.
It appears that you have set the Content for the ContentPage as DataGrid in OrderInfoRepositoryView.xaml.cs file. Please refer to the below file,
https://github.com/JeanMarcFlamand/MauiSyncFusionExamples/blob/master/DataGrid/Views/OrderInfoRepositoryView.xaml.cs#L12
You are adding the DataGrid as the content of the page in code behind i.e., OrderInfoRepositoryView constructor. That’s why the DataGrid alone is displaying without Label. We request that you remove the codes inside the OrderInfoRepositoryView constructor to overcome the issue.

PowerShell XAML iOS style On/Off Button

As the name suggests, I'm trying to create an on/off type button using XAML and PowerShell, but cannot for the life of me find any guides or code on the internet.
I found a page with a great demo. Link here.
This is how the code begins.
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Viewbox>
<Border x:Name="Border" CornerRadius="10"
When using XAML for PowerShell we can't utilise x: at all.
Here's another more indepth answer right here on StackOverflow. Same issue. There doesn't seem to be any resources for doing this without the dreaded x:
Anyone any ideas?
U need to copy the style under here:
<Window.Resources>
<Style Key=“MyToggleStyle“ TargetType="ToggleButton">
Then u can use it on your button like this:
<ToggleButton Style="{StaticResource MyToggleStyle}" />
U can simply drop the x:
Name="Border"
TargetType="ToggleButton"

How to enable Grommet sidebar menu within split on mobile

Hi I'm new to Grommet and development in general. I'm having some trouble with displaying a mobile menu.
When a screen hits a certain size the split view shows only the right side of the screen, giving you no access to the menu.
<App centered={false}>
<Split separator={true} flex='right' fixed={true} colorIndex='brand'>
<Sidebar colorIndex='brand' responsive={true}>
<Header pad='small' justify='between'>
<Title> brand </Title>
</Header>
<Box flex='grow' justify='start'>
<Menu primary={true}>
<Anchor key="home" path="/app" label="Home" />
</Menu>
</Box>
</Sidebar>
<Box>
{this.props.children}
</Box>
</Split>
</App>
From what I can tell you just need a title in a header on the right side that is set to responsive={true}. This will display your heading if your device is a mobile.
<div>
<Header pad='small' justify='between' responsive={true}>
<Title> brand </Title>
</Header>
<Cards />
</div>
This doesn't seem to work. The header displays the whole time. What I ideally want is to display the header from the sidebar.
Can anyone please help me achieve this?

How to fix the App name on the top of the Activity

In my design page of My Android Studio Project, the App Name is shown in the top of the activity(Action Bar). But, when I debug the App, the App name is not Shown on the top of the Activity. I want the App name should be shown. How to fix it.
My styles.xml is...
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Set your App theme to Theme.AppCompat.Light.DarkActionBar in style.xml
For e.g.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
I think you was asking about ActionBar
from docs
A primary toolbar within the activity that may display the activity
title, application-level navigation affordances, and other interactive
items.
Beginning with Android 3.0 (API level 11), the action bar appears at
the top of an activity's window when the activity uses the system's
Holo theme (or one of its descendant themes), which is the default.
You may otherwise add the action bar by calling
requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom
theme with the windowActionBar property.
If you want to change it from java code, write in
Activity.java
ActionBar ab = getActionBar();
ab.setTitle("My new title");
Or, in the Androidmanifest.xml file:
<activity
android:name=".MyActivity"
android:icon="#drawable/my_icon"
android:label="My new title" />
hope my answer help you..