Item double click (run or open)

This commit is contained in:
2023-08-03 11:17:51 +02:00
parent 558a0a08bb
commit 3304d775f5
10 changed files with 66 additions and 77 deletions

View File

@@ -478,7 +478,10 @@
x:Name="CurrentItems">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="corevm:IItemViewModel">
<local:ItemView HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
<local:ItemView
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
PointerPressed="Child_OnPointerPressed" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

View File

@@ -184,4 +184,26 @@ public partial class MainWindow : Window, IUiAccessor
public async Task InvokeOnUIThread(Func<Task> func) => await Dispatcher.UIThread.InvokeAsync(func);
public async Task<T> InvokeOnUIThread<T>(Func<Task<T>> func) => await Dispatcher.UIThread.InvokeAsync(func);
private async void Child_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
if (e is {Handled: false, ClickCount: 2}
&& ViewModel != null
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
&& sender is StyledElement {DataContext: IItemViewModel itemViewModel})
{
try
{
await ViewModel.RunOrOpenItem(itemViewModel);
}
catch (Exception ex)
{
_logger?.LogError(
ex,
"Error while opening item {Item}",
itemViewModel.BaseItem?.FullName?.Path ?? itemViewModel.DisplayNameText
);
}
}
}
}