Skip to content

Commit

Permalink
ListViewItem double click to start game
Browse files Browse the repository at this point in the history
  • Loading branch information
bburky committed Oct 22, 2021
1 parent cba8593 commit 49cae63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions PlaylistView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
</MultiDataTrigger>
</Style.Triggers>

<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick"/>

<Setter Property="ContextMenu">
<!-- Only set the ContextMenu for ListViewItems to avoid a ContextMenu on the header -->
<Setter.Value>
Expand Down Expand Up @@ -166,7 +168,6 @@
</DataTrigger>
</Style.Triggers>
</Style>

</UserControl.Resources>

<DockPanel>
Expand All @@ -181,7 +182,7 @@
Style="{StaticResource BaseTextBlockStyle}"
Margin="10,0,0,0" FontSize="18"/>
</StackPanel>

<ListView
x:Name="playlistListView"
ItemsSource="{Binding PlaylistGames}"
Expand All @@ -191,6 +192,7 @@
SelectedIndex="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True">

<ListView.InputBindings>
<KeyBinding
Key="Delete"
Expand Down
6 changes: 6 additions & 0 deletions PlaylistView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public PlaylistView(PlaylistViewModel model)
DataContext = model;
InitializeComponent();
}

private void OnItemDoubleClick(object sender, MouseButtonEventArgs e)
{
Control item = sender as Control;
(DataContext as PlaylistViewModel)?.StartGameCommand.Execute(item?.DataContext);
}
}
}

0 comments on commit 49cae63

Please sign in to comment.