I’ve written a custom DataTemplate for items in a ListView, something like this:
<DataTemplate x:Key="CustomerStateTemplate">
<Grid Margin="5, 5, 5, 5">
<Grid.ColumnDefinitions>
...
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
...
</Grid.RowDefinitions>
<Image Grid.Row="0" Grid.RowSpan="2" Width="24" Height="20" ... />
<TextBox Style="{StaticResource CustomerStyle}" Grid.Column="0"
Grid.Row="0" Grid.ColumnSpan="2"
Name="nameField">
<TextBox.Text>
<Binding Path="Name" />
</TextBox.Text>
</TextBox>
...
and I’ve obtain my pretty style.
Now, if I want to select the item, I must click on the white space between the template controls. If I click on the textbox in the ListViewItem, it won’t select like an item. So, is there a way to select a ListViewItem by clicking on the controls in its template?
Thanks thousand!
Its possible to add a trigger on the ListViewItem which selects the item always then the keyboardfocus is inside of the item. As you do that on the ListViewItem you have the same behavior for all the controls inside the DataTemplate, which should be your solution…
example:
i hope its clear…