2025-12-01 02:32:30 +01:00
|
|
|
|
// 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.Core.ViewModels;
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.CmdPal.UI;
|
|
|
|
|
|
|
|
|
|
|
|
internal sealed partial class GridItemContainerStyleSelector : StyleSelector
|
|
|
|
|
|
{
|
|
|
|
|
|
public IGridPropertiesViewModel? GridProperties { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Style? Small { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Style? Medium { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Style? Gallery { get; set; }
|
|
|
|
|
|
|
2026-01-08 21:23:38 +01:00
|
|
|
|
public Style? Section { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Style? Separator { get; set; }
|
|
|
|
|
|
|
2025-12-01 02:32:30 +01:00
|
|
|
|
protected override Style? SelectStyleCore(object item, DependencyObject container)
|
|
|
|
|
|
{
|
2026-01-08 21:23:38 +01:00
|
|
|
|
if (item is ListItemViewModel { IsSectionOrSeparator: true } listItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.IsNullOrWhiteSpace(listItem.Title)
|
|
|
|
|
|
? Separator!
|
|
|
|
|
|
: Section;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-01 02:32:30 +01:00
|
|
|
|
return GridProperties switch
|
|
|
|
|
|
{
|
|
|
|
|
|
SmallGridPropertiesViewModel => Small,
|
|
|
|
|
|
MediumGridPropertiesViewModel => Medium,
|
|
|
|
|
|
GalleryGridPropertiesViewModel => Gallery,
|
|
|
|
|
|
_ => Medium,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|