cannot to add new page on .net maui visual studio 2022 for mac

Sergio Daniel Toro Romero 21 Reputation points
2022-05-31T00:38:18.173+00:00

How to add new page on visual studio for Mac 2022

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

2 answers

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 28,876 Reputation points Microsoft Vendor
    2022-05-31T02:25:22.5+00:00

    Hello @Sergio Daniel Toro Romero ,

    VS for mac MAUI tooling is still under preview, some file templates are not ready yet. If you want to create a page, try to create a class inherited from ContentPage, refer to the following code :

     public class MyPage : ContentPage  
     	 {  
     	     public MyPage ()  
           {  
               Content = new StackLayout{  
      	             Children ={  
      	                 ......  
        	             }  
       	         };  
       	     }  
       	 }  
    

    If you want to create a page with Xaml, try to create an empty file named MyPage.xaml, and add the control element, refer to the following code:

    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"  
    	  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
    	  x:Class="XXX.MyPage">  
    	 <ContentPage.Content>  
    	     <StackLayout>...  
    	 </StackLayout>  
    	 </ContentPage.Content>  
    	 </ContentPage>  
    

    Then add an empty class as partial class of this page, and implement InitializeComponent() method, note that the class file is named MyPage.xaml.cs :

    namespace xxx  
    	  {  
    	       public  partial class MyPage : ContentPage  
             {  
                 public MyPage()  
                 {  
                     InitializeComponent();  
                 }  
             }  
         }  
    

    Best Regards,
    Wenyan Zhang


    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

  2. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 28,876 Reputation points Microsoft Vendor
    2022-06-16T06:08:50.91+00:00

    Hello @Sergio Daniel Toro Romero ,

    Please check the Visual Studio 2022 for Mac v17.3 Preview 2

    Top updates include:

    • New File / Item templates are now shown for .NET MAUI projects.
    0 comments No comments