Idk, dev work goin on
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// A DataTemplateSelector that selects the appropriate DataTemplate based on the type of server item (StandaloneServerViewModel or SubscriptionServerViewModel).
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user