I'm using a custom ListBoxItem, that's built like this
<Style x:Key="MyListBoxItem" TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border>
<Border>
<ContentPresenter />
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
It's a basic structure which is modified for the editing control that I need, like this
<Style x:Key="MyListBoxItemText" TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ListBoxItem Style="{DynamicResource MyListBoxItem}">
<TextBox />
</ListBoxItem>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The used ListBoxItem for a certain record of the used ItemsSource of the ListBox is chosen by a StyleSelector.
What I need is a possibility to access the ListBoxItem, thats currently focused. I've tried the following
- set the IsSyncronizedWithCurrentItem-property of the ListBox to true
- try to grab the SelectionChanged Event of the ListBox
- monitor the IsSelected property of the ListBoxItem
- define (Multi)Trigger in the basic style for the ListBoxItem
- set an EventSetter
Can anyone help me, please?
Thanks a lot in advance
Alright, here are my attempts:
In the style of the ListBox the IsSyncronizedWithCurrentItem property is set to true.