mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
Functionally, no differences. - Removed Core projects. - Core.Common => Microsoft.CmdPal.Common - Core.ViewModels => Microsoft.CmdPal.UI.ViewModels --------- Co-authored-by: Jiří Polášek <me@jiripolasek.com>
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using Microsoft.CmdPal.UI.ViewModels;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
namespace Microsoft.CmdPal.UI;
|
|
|
|
internal sealed partial class GridItemTemplateSelector : DataTemplateSelector
|
|
{
|
|
public IGridPropertiesViewModel? GridProperties { get; set; }
|
|
|
|
public DataTemplate? Small { get; set; }
|
|
|
|
public DataTemplate? Medium { get; set; }
|
|
|
|
public DataTemplate? Gallery { get; set; }
|
|
|
|
public DataTemplate? Section { get; set; }
|
|
|
|
public DataTemplate? Separator { get; set; }
|
|
|
|
protected override DataTemplate? SelectTemplateCore(object item, DependencyObject dependencyObject)
|
|
{
|
|
if (item is not ListItemViewModel element)
|
|
{
|
|
return Medium;
|
|
}
|
|
|
|
switch (element.Type)
|
|
{
|
|
case ListItemType.Separator:
|
|
return Separator;
|
|
case ListItemType.SectionHeader:
|
|
return Section;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return GridProperties switch
|
|
{
|
|
SmallGridPropertiesViewModel => Small,
|
|
MediumGridPropertiesViewModel => Medium,
|
|
GalleryGridPropertiesViewModel => Gallery,
|
|
_ => Medium,
|
|
};
|
|
}
|
|
}
|