Forum Discussion
How do you add an image logo to the Title header of a ContentPage?
Right now, following James Montemagno's tutorials on .NET MAUI, the Title header of my content pages just consists of a text string, but I would like an image logo there. Any way to do it?
- LanHuangMicrosoft
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang - jhons122Copper Contributor
To add an image logo to the Title header of a ContentPage, you can use the Image property of TitleView. Just set the Image property to the desired logo image and it will be displayed in the header. You can also optionally provide a TapGestureRecognizer to the TitleView to make the logo image clickable.- Daniel_Donnelly_JrCopper Contributor
- Daniel_Donnelly_JrCopper ContributorAlso, is there a way to simply add it to all ContentPage headers?
- Daniel_Donnelly_JrCopper Contributor
That doesn't work:
```
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage x:Class="CEDDashboard.View.SettingsDetailPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodel="clr-namespace:CEDDashboard.ViewModel"
xmlns:local="clr-namespace:CEDDashboard.View"
x:DataType="viewmodel:SettingsDetailViewModel"
Title="{Binding Device.Name}"><NavigationPage.TitleView>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center" Orientation="Horizontal">
<Image HorizontalOptions="Start" Source="app_logo.png" />
<Label HorizontalOptions="Start" VerticalTextAlignment="Center" Text="Device Detail Settings" FontSize="Small"/>
</StackLayout>
</NavigationPage.TitleView>
<ContentPage.Content>
<VerticalStackLayout>
<Image HorizontalOptions="Start" Source="app_logo.png" />
<ScrollView BackgroundColor="{AppThemeBinding Light={StaticResource LightBackground}, Dark={StaticResource DarkBackground}}">
<Grid RowDefinitions="Auto,Auto,*">
<BoxView```
The only image that is displayed is the one inside my content. The NavigationPage.TitleView trick doesn't show any image.