mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Closes #38269 Still working on this one, but essentially allows a list page to become a grid page by specifying a `GridProperties` property like so: ```C# public AllAppsPage() { PlaceholderText = Resources.search_installed_apps_placeholder; GridProperties = new MediumGridLayout(); } ``` > This is a very early version and very subject to change. Much to clean, but feedback & suggestions are welcome. ## Current preview ### SmallGridLayout <img width="998" height="607" alt="image" src="https://github.com/user-attachments/assets/ebdf11fd-6c86-4fc3-bf49-bcbb5d32caa4" /> ### MediumGridLayout <img width="976" height="586" alt="image" src="https://github.com/user-attachments/assets/82daa2e9-548e-4864-8885-1c486ca9f891" /> ### GalleryGridLayout <img width="988" height="600" alt="image" src="https://github.com/user-attachments/assets/23ca486a-35c7-467a-b200-4f6ee5f4a95c" /> --------- Co-authored-by: Mike Griese <migrie@microsoft.com>
41 lines
1.1 KiB
C#
41 lines
1.1 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.Core.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; }
|
|
|
|
protected override DataTemplate? SelectTemplateCore(object item, DependencyObject dependencyObject)
|
|
{
|
|
DataTemplate? dataTemplate = Medium;
|
|
|
|
if (GridProperties is SmallGridPropertiesViewModel)
|
|
{
|
|
dataTemplate = Small;
|
|
}
|
|
else if (GridProperties is MediumGridPropertiesViewModel)
|
|
{
|
|
dataTemplate = Medium;
|
|
}
|
|
else if (GridProperties is GalleryGridPropertiesViewModel)
|
|
{
|
|
dataTemplate = Gallery;
|
|
}
|
|
|
|
return dataTemplate;
|
|
}
|
|
}
|