How to add an image to title bar in Xamarin Forms UWP?

Copper Contributor

Hello, I've been trying to add an icon to the title bar in Xamarin Forms UWP, but couldn't. I've search several articles and most of them were for native UWP apps. I tried to implement the same way to my Xamarin Forms UWP, but it didn't work. 

Here are my changes:

FirstPage.xaml

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <Grid x:Name="AppTitleBar">
        <Rectangle x:Name="BackgroundElement" Fill="Transparent" />
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Height="32" Margin="5,0" Source="Assets/StoreLogo.png" />
            <TextBlock Grid.Column="1" VerticalAlignment="Center" Text="My Mobile App" />
        </Grid>
    </Grid>
</Grid>

FirstPage.xaml.cs:

 

public sealed partial class FirstPage
{
public FirstPage()
{
this.InitializeComponent();

// Hide default title bar.
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = false;

// Set XAML element as a drag region.
Window.Current.SetTitleBar(AppTitleBar);



Syncfusion.SfDataGrid.XForms.UWP.SfDataGridRenderer.Init();

LoadApplication(new MainApp());
}

 

 This change only extends my app to the title bar, but didn't add the AppTitleBar content. Could you please help me with this issue? Thank you.

1 Reply

Hi @pvhd84,

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