-
Notifications
You must be signed in to change notification settings - Fork 14
MAUI Conventions
Strypper Vandel Jason edited this page Apr 17, 2023
·
5 revisions
- Traditional approach
- Easy to understand
- Clunky to setup
- Outdated
- Tightly coupled
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
x:Class="PetaverseMAUI.PetProfileCardContentView"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:app="clr-namespace:PetaverseMAUI"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Name="root"
Padding="10"
x:DataType="app:PetProfileCardContentView">
<ContentView.Resources>
<FontImageSource
x:Key="GalleryIcon"
FontFamily="{x:Static app:FontNames.FluentSystemIconsRegular}"
Glyph="{x:Static app:FluentUIIcon.Ic_fluent_content_view_gallery_28_regular}"
Color="{x:Static app:AppColors.Black}" />
</ContentView.Resources>
<Button Clicked="Detail_Clicked" Text="Detail" />
</ContentView>
#region [ Delegates ]
public delegate void PetCardTappedEventHandler(PetProfileCardModel petProfileCardModel);
#endregion
#region [ Event Handlers ]
public event PetCardTappedEventHandler PetCardTapped;
private void Detail_Clicked(object sender, EventArgs e)
=> PetCardTapped?.Invoke(ComponentData);
#endregion
<DataTemplate x:Key="PetsCollectionViewItemTemplate" x:DataType="app:PetProfileCardModel">
<app:PetProfileCardContentView ComponentData="{x:Binding}" PetCardTapped="PetProfileCardContentView_PetCardTapped" />
</DataTemplate>
private void PetProfileCardContentView_PetCardTapped(PetProfileCardModel petProfileCardModel){}