Skip to content

Commit

Permalink
Move DataTemplateSelector to own file in template (#26489)
Browse files Browse the repository at this point in the history
* Move DataTemplateSelector to own file in template

* Update ChipDataTemplateSelector.cs
  • Loading branch information
jfversluis authored Dec 10, 2024
1 parent c6584a0 commit 366e5c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</Border>
</DataTemplate>

<pages:ChipDataTemplateSelector
<controls:ChipDataTemplateSelector
x:Key="ChipDataTemplateSelector"
NormalTagTemplate="{StaticResource NormalTagTemplate}"
SelectedTagTemplate="{StaticResource SelectedTagTemplate}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 366e5c8

Please sign in to comment.