How can I change Animation, Transitions and Styling from WinUI's App.xaml in .NET MAUI?

Mohammad Hossein Rastegarinia 21 Reputation points
2023-05-25T21:40:14.3233333+00:00

I used to give my layouts and controls some native animations and styles for UWP back in Xamarin.Forms like this:

<Application
    xmlns:uwp="using:Xamarin.Forms.Platform.UWP">
    <Application.Resources>
        <ResourceDictionary>
            <Style x:Key="EllipsisButton" TargetType="Button">
                <Setter Property="MaxWidth" Value="0"/>
            </Style>

            <Style TargetType="uwp:FormsCommandBar" >
                <Setter Property="DefaultLabelPosition" Value="Right" />
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="OverflowButtonVisibility" Value="Collapsed"/>
            </Style>

            <Color x:Key="SystemAccentColor">#66E91E63</Color>
            <x:Double x:Key="AppBarThemeCompactHeight">48</x:Double>
           
            <Style TargetType="uwp:LayoutRenderer">
                <Setter Property="Transitions">
                    <Setter.Value>
                        <TransitionCollection>
                            <RepositionThemeTransition />
                        </TransitionCollection>
                    </Setter.Value>
                </Setter>
                <Setter Property="ChildrenTransitions">
                    <Setter.Value >
                        <TransitionCollection>
                            <EntranceThemeTransition/>
                        </TransitionCollection>
                    </Setter.Value>
                </Setter>
            </Style>
            
        </ResourceDictionary>
    </Application.Resources>
</Application>

Is it possible on MAUI for WinUI too? I couldn't find any namespace from source code to replace xmlns:uwp="using:Xamarin.Forms.Platform.UWP"! Also Intelisenese not working in Windows's App.xaml so my only option was to asking you guys.

Windows development | Windows App SDK
Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-05-26T03:23:22.1466667+00:00

    Hello,

    For how to animate, transition and style controls in MAUI's xaml, you could refer to the solution in this thread: Can we able to modify the design of toggle switch in maui ?.

    After you copy the default styles corresponding to the native controls to Platforms\Windows\App.xaml, you could modify the properties in the same way you modify the native WinUI3 control styles.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.