How to change the Title bar background color in Xamarin.Forms wpf application?

Praveen.BPraveen.B ✭✭INMember ✭✭

Hello everyone,

I am doing an application in wpf with xamarin.forms in which i need to change the title bar background color to mach with our theme.But by default a blue color background is appearing.Can anyone please help and guide me to resolve this issue.

Tagged:

Answers

  • BillyLiuBillyLiu Xamurai Member, Xamarin Team Xamurai

    @Praveen.B

    You could use a custom window style. And create ControlTemplate for the window. and set the background in the template. For example the

        <ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}">
            <Grid Background="{StaticResource WindowBackColor}">
             ......
    

    and the WindowBackColor

        <SolidColorBrush x:Key="WindowBackColor" Color="Orange"/>
    

    The style:

        <Style x:Key="CustomWindowStyle" TargetType="{x:Type Window}">
             ...
            <Setter Property="Template" Value="{StaticResource WindowTemplate}"/>
            ...
        </Style>
    

    Finally set the style in wpf project MainWindow.xaml

     Style="{StaticResource CustomWindowStyle}"
    

    Please refer to the following tutorial for more information:
    https://code.msdn.microsoft.com/windowsdesktop/WPF-styling-a-Window-in-fcf4e4ce

Sign In or Register to comment.