mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
CmdPal: Add Context Menu command "Show Details" when list item has details, but list view's ShowDetails == false (#40870)
Closes #38270 When a list item's `Details` property is not null, but it's parent ListViews `ShowDetails` property is false, this PR adds a context menu item at the bottom of the commands for the list item to show details. Clicking that command will show the details for the selected item, but the details pane will hide when a different item is selected. ## Preview https://github.com/user-attachments/assets/7b5cd3d4-b4ae-433a-ad25-f620590cd261 --------- Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
This commit is contained in:
@@ -247,32 +247,46 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
||||
|
||||
public void Receive(ShowDetailsMessage message)
|
||||
{
|
||||
// TERRIBLE HACK TODO GH #245
|
||||
// There's weird wacky bugs with debounce currently.
|
||||
if (!ViewModel.IsDetailsVisible)
|
||||
if (ViewModel is not null &&
|
||||
ViewModel.CurrentPage is not null)
|
||||
{
|
||||
ViewModel.Details = message.Details;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HasHeroImage)));
|
||||
ViewModel.IsDetailsVisible = true;
|
||||
return;
|
||||
if (ViewModel.CurrentPage.PageContext.TryGetTarget(out var pageContext))
|
||||
{
|
||||
Task.Factory.StartNew(
|
||||
() =>
|
||||
{
|
||||
// TERRIBLE HACK TODO GH #245
|
||||
// There's weird wacky bugs with debounce currently.
|
||||
if (!ViewModel.IsDetailsVisible)
|
||||
{
|
||||
ViewModel.Details = message.Details;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HasHeroImage)));
|
||||
ViewModel.IsDetailsVisible = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// GH #322:
|
||||
// For inexplicable reasons, if you try to change the details too fast,
|
||||
// we'll explode. This seemingly only happens if you change the details
|
||||
// while we're also scrolling a new list view item into view.
|
||||
_debounceTimer.Debounce(
|
||||
() =>
|
||||
{
|
||||
ViewModel.Details = message.Details;
|
||||
|
||||
// Trigger a re-evaluation of whether we have a hero image based on
|
||||
// the current theme
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HasHeroImage)));
|
||||
},
|
||||
interval: TimeSpan.FromMilliseconds(50),
|
||||
immediate: ViewModel.IsDetailsVisible == false);
|
||||
ViewModel.IsDetailsVisible = true;
|
||||
},
|
||||
CancellationToken.None,
|
||||
TaskCreationOptions.None,
|
||||
pageContext.Scheduler);
|
||||
}
|
||||
}
|
||||
|
||||
// GH #322:
|
||||
// For inexplicable reasons, if you try to change the details too fast,
|
||||
// we'll explode. This seemingly only happens if you change the details
|
||||
// while we're also scrolling a new list view item into view.
|
||||
_debounceTimer.Debounce(
|
||||
() =>
|
||||
{
|
||||
ViewModel.Details = message.Details;
|
||||
|
||||
// Trigger a re-evaluation of whether we have a hero image based on
|
||||
// the current theme
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(HasHeroImage)));
|
||||
},
|
||||
interval: TimeSpan.FromMilliseconds(50),
|
||||
immediate: ViewModel.IsDetailsVisible == false);
|
||||
ViewModel.IsDetailsVisible = true;
|
||||
}
|
||||
|
||||
public void Receive(HideDetailsMessage message) => HideDetails();
|
||||
|
||||
Reference in New Issue
Block a user