Prism Quickstart: Issues Swapping ListView for Grid

Topics: Prism v4 - WPF 4
Jun 28, 2011 at 11:51 PM

I'm brand new to Prism and have installed the Prism template packs for visual studio and created a PrismQuickstart project which works great.  The quick start contains a project called "Module1" that loads a ListBox in the MasterView.xaml which works fine.  When an item is selected in the listbox the following code is called which opens the selected item in another view calld EditView.xaml.

                   
  <!--Bind to commands on the view model from within each list box item-->
  <Button prism:Click.Command="{Binding DataContext.NavigateToViewCommand, ElementName=DataItemListBox}"
                					    prism:Click.CommandParameter="{Binding GUID}" Margin="2"
                                        ToolTipService.ToolTip="Click to navigate to the Edit View for this item.">
                                    <Image Height="20" Width="20" Source="/Module1;component/Images/NavigateToView.png" />
                                </Button>

I'm attempting to remove the ListBox and put in a DataGrid.  I can get the DataGrid bound to the ViewModel with no problem, but I have no idea how to make it so when a grid row is selected, the selected item displays.

Any suggestions?

Thank you.

Jun 29, 2011 at 6:49 PM

Hi,

Based on my understanding of your scenario, you could hook a Custom Command Behavoir to the DataGrid’s SelectionChanged event (or the event that you choose, based on your requirements).

You can check the following thread where the custom command behavior creation is explained.

I hope you find this information useful.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic