You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MyFirstMAUI/MyFirstMauiApp/CollectionViewDemos/Controls/MonkeyDataTemplateSelector.cs

22 lines
635 B

using CollectionViewDemos.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CollectionViewDemos.Controls
{
internal class MonkeyDataTemplateSelector : DataTemplateSelector
{
public DataTemplate AmericanMonkey { get; set; }
public DataTemplate OtherMonkey { get; set; }
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
Monkey monkey = (Monkey)item;
return monkey.Location.Contains("America") ? AmericanMonkey : OtherMonkey;
}
}
}