using System; using System.Collections.Generic; using System.Text; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using WinWARP.Core.ViewModels.Wrappers; namespace WinWARP.Ui.Helpers; /// /// A DataTemplateSelector that selects the appropriate DataTemplate based on the type of server item (StandaloneServerViewModel or SubscriptionServerViewModel). /// public class ServerTemplateSelector : DataTemplateSelector { public DataTemplate StandaloneTemplate { get; set; } public DataTemplate SubscriptionTemplate { get; set; } protected override DataTemplate SelectTemplateCore(object item) { // Evaluate the type of the item currently being rendered in the list row return item switch { StandaloneServerViewModel => StandaloneTemplate, SubscriptionServerViewModel => SubscriptionTemplate, _ => base.SelectTemplateCore(item) // Fallback if type doesn't match }; } }