I have created a listbox with editable textboxes. The code looks like this:
<ListBox Name="subjects_list" Margin="74,154,1039,171" ItemsSource="{Binding ElementName=styles_list, Path=SelectedItem.subjects, Mode=TwoWay}" HorizontalContentAlignment="Stretch" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Name="TextBoxList" Text="{Binding name}" BorderThickness="1" Background="#FFD3E1FF" BorderBrush="#FFA0B8FF" >
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="IsReadOnly" Value="False" />
</Trigger>
<Trigger Property="IsFocused" Value="False">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="IsReadOnly" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I want to change the behaviour of this setup as it turned out to be not exactly what I need. The problem is that on a mouse click, the textbox becomes editable but it is not the selected item in the listbox. I need to have a way to select the item and another way to edit it. My idea is that on a single click I set the textbox as selected item and on a double click the textbox becomes editable. Any suggestions how to achieve this?