Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DataTemplateSelector to own file in template #26489

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}