CP - Content Page
For example: MainWindow.xaml.cs - CP
MobileWindow.xaml.cs - CP DesktopWindow.xaml.cs - CP
And I want If I have IOS or Android in MainWindow.xaml.cs load MobileWindow.xaml.cs
If desktop->load Desktop.xaml.cs
Help me please,) MainWindow.xaml.cs can inherits from other class. Give me best solution. But MainWindow.xaml.cs must be replaced by own by CP.
If you can use in xaml OnPlatform please)
I found solution:
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MegaProj"
xmlns:Desktop="clr-namespace:MegaProj.Views.MainPageView.Desktop"
xmlns:Mobile="clr-namespace:MegaProj.Views.MainPageView.Mobile"
xmlns:viewModel="clr-namespace:MegaProj.ViewModel"
xmlns:convertors="clr-namespace:MegaProj.Convertors"
x:Class="MegaProj.Views.MainPage.MainPageView">
<Shell.Resources>
<ResourceDictionary>
<DataTemplate x:Key="DesktopTemplate">
<Desktop:MainPageDesktopView />
</DataTemplate>
<DataTemplate x:Key="MobileTemplate">
<Mobile:MainPageMobileView />
</DataTemplate>
</ResourceDictionary>
</Shell.Resources>
<ShellContent>
<ShellContent.ContentTemplate>
<OnPlatform x:TypeArguments="DataTemplate">
<On Platform="WinUI, MacCatalyst" Value="{StaticResource DesktopTemplate}" />
<On Platform="iOS, Android" Value="{StaticResource MobileTemplate}" />
</OnPlatform>
</ShellContent.ContentTemplate>
</ShellContent>
</Shell>
WHERE <Desktop:MainPageDesktopView />
, <Mobile:MainPageMobileView />
- Content Pages