From 366e5c8cde9ca0a9c2a1e714ea9f08f38b9e5341 Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Tue, 10 Dec 2024 18:56:21 +0100 Subject: [PATCH] Move DataTemplateSelector to own file in template (#26489) * Move DataTemplateSelector to own file in template * Update ChipDataTemplateSelector.cs --- .../Pages/Controls/ChipDataTemplateSelector.cs | 14 ++++++++++++++ .../maui-mobile/Pages/ProjectDetailPage.xaml | 2 +- .../maui-mobile/Pages/ProjectDetailPage.xaml.cs | 11 ----------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs diff --git a/src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs b/src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs new file mode 100644 index 000000000000..55ccbe0cfa52 --- /dev/null +++ b/src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs @@ -0,0 +1,14 @@ +using MauiApp._1.Models; + +namespace MauiApp._1.Pages.Controls; + +public class ChipDataTemplateSelector : DataTemplateSelector +{ + public required DataTemplate SelectedTagTemplate { get; set; } + public required DataTemplate NormalTagTemplate { get; set; } + + protected override DataTemplate OnSelectTemplate(object item, BindableObject container) + { + return (item as Tag)?.IsSelected ?? false ? SelectedTagTemplate : NormalTagTemplate; + } +} \ No newline at end of file diff --git a/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml b/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml index b9652a40895e..33b2d0e1d0b2 100644 --- a/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml +++ b/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml @@ -46,7 +46,7 @@ - diff --git a/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml.cs b/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml.cs index 2fc84dc9f272..b6e56aec69cb 100644 --- a/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml.cs +++ b/src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml.cs @@ -11,14 +11,3 @@ public ProjectDetailPage(ProjectDetailPageModel model) BindingContext = model; } } - -public class ChipDataTemplateSelector : DataTemplateSelector -{ - public required DataTemplate SelectedTagTemplate { get; set; } - public required DataTemplate NormalTagTemplate { get; set; } - - protected override DataTemplate OnSelectTemplate(object item, BindableObject container) - { - return (item as Tag)?.IsSelected ?? false ? SelectedTagTemplate : NormalTagTemplate; - } -} \ No newline at end of file