first page to be a windows

Eduardo Gomez Romero 905 Reputation points
2024-11-19T20:35:22.4833333+00:00

Hello

In my app I have am MainPage and a MainWindow

What I want to do is that if I'm on desktop, the first page to be MainWindow, if not to be the mainPage

Screenshot 2024-11-19 224525


 public partial class App : Application
 {
     public App()
     {
         InitializeComponent();
     }
     protected override Window CreateWindow(IActivationState? activationState)
     {
         return new Window(new AppShell());
     }

 }



<Shell
    x:Class="Cross_platform.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:vews="clr-namespace:Cross_platform.Views"
    Title="Cross_platform"
    Shell.FlyoutBehavior="Flyout">

    <ShellContent
        x:Name="DynamiShell"
        Title="Home" />

</Shell>

public partial class AppShell : Shell {
        public AppShell() {
            InitializeComponent();
            if (DeviceInfo.Idiom == DeviceIdiom.Phone) {
                DynamiShell.ContentTemplate = new DataTemplate(typeof(MainPage));
            }
            else {
                Application.Current.OpenWindow(new MainWindow());
            }
            Register();
        }
        private static void Register() {
            Routing.RegisterRoute(nameof(Window1), typeof(Window1));
            Routing.RegisterRoute(nameof(Page1), typeof(Page1));
        }
    }
}


No Content found for ShellContent, Title:Home, Route D_FAULT_ShellContent2

I have a qustion

So know I have to create DesktopViews amd Mobileviews?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,648 questions
{count} votes

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.