Reputation: 16979
I have the following XAML. I want one button per row to encompass all the data. Is this possible?
<ListView Name="ClosestListView">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="ShapeFileType" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ShapeFileType}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Address" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=fullMatch}" MinWidth="100"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
... more columns and closing tags
Upvotes: 1
Views: 182
Reputation: 132618
If you're just looking to add a Click event to your Row, you would probably be better off adding a Click event to your ListViewItem
or GridViewCell
<Style TargetType="{x:Type ListViewItem}">
<EventSetter Event="MouseDoubleClick" Handler="HandleDoubleClick" />
</Style>
If you want to bind the click event to a Command
in your ViewModel, I'd suggest using the AttachedCommandBehavior
found here
And if you really want a button that spams all columns, I would recommend looking into Grid.SharedSizeGroup to align your data
Upvotes: 2
Reputation: 16979
I guess its more logical to just handle selectionchanged event.
<ListView Name="ClosestListView" SelectionChanged="ClosestListView_SelectionChanged">
Upvotes: 0