How would you change the behavior of ListView so that the selection of the record happens immediately, by the focus of the mouse or the navigation keys?
I do not think where it should be, what we have:
<ListView x:Name="listText" Grid.Row="0" Grid.Column="0" Margin="10,2,0,2" Height="250" BorderThickness="1" SelectedIndex="-1" ItemsSource="{local:SettingBinding TextToSend}" Style="{StaticResource VirtualisedMetroListView}"> <ListView.View> <GridView> <GridViewColumn Width="850"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneTime}" BorderThickness="0" Background="Transparent" IsReadOnly="True" MouseDoubleClick="txt_MouseDoubleClick" KeyDown="txt_KeyDown" CtrlMh:TextBoxHelper.Watermark="Enter new text" CtrlMh:TextBoxHelper.WatermarkWrapping="WrapWithOverflow" SpellCheck.IsEnabled="{local:SettingBinding IsSpellCheck}" Width="{Binding ActualWidth, ElementName=listText, Mode=OneWay}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> UPD Possible solution:
<ListView x:Name="listText" Grid.Row="0" Grid.Column="0" Margin="10,2,0,2" Height="250" BorderThickness="1" SelectedIndex="-1" ItemsSource="{local:SettingBinding TextToSend}" Style="{StaticResource VirtualisedMetroListView}"> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Setter Property="IsSelected" Value="True" /> </Trigger> </Style.Triggers> </Style> </ListView.ItemContainerStyle> <ListView.View> <GridView> <GridViewColumn Width="820"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneTime}" BorderThickness="0" Background="Transparent" IsReadOnly="True" MouseDoubleClick="txt_MouseDoubleClick" KeyDown="txt_KeyDown" CtrlMh:TextBoxHelper.Watermark="Enter new text" CtrlMh:TextBoxHelper.WatermarkWrapping="WrapWithOverflow" SpellCheck.IsEnabled="{local:SettingBinding IsSpellCheck}" Language="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}},Path=DataContext.CultureCurent}" Width="{Binding ActualWidth, ElementName=listChatText, Mode=OneWay}"> <SpellCheck.CustomDictionaries> <CtrlSys:Uri>pack://application:,,,/spellwords.lex</CtrlSys:Uri> </SpellCheck.CustomDictionaries> </TextBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> 
ListViewItembe selected when you hover the mouse or what? - Andrey NOP