I have a Contextmenu with a ListBox inside. Whenever I right click my control and select a value from my contextmenu the last selected value stays marked and I can't select that value again.
The idea is, that I may select the same value within the COntextmenu in order to turn a property on or off.
Should be quite basic, what am I missing?
Many Thanks,
EDIT: Thanks for the responses. I have tried to apply your ideas without success. I think the major problem is that MenuItems of a contextmenu have no ItemSource to be bound to a collection (e.g. PossibleValues as in this example).
May I insert my code for clarification:
<Border.ContextMenu>
<ContextMenu>
<ContextMenu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property ="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<ContentPresenter x:name="Header" ContentSource="Header" RecognizesAccessKey="True"/>
</ControlTemplate>
</Setter.value>
</Setter>
</Style>
<ContextMenu.ItemContainerStyle>
<ListBox BorderThickness="0" Width="35" Margin="0"
SelectedItem="{Binding Path=Volume, Mode=TwoWay}
DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}"
ItemsSource="{Binding Path=PossibleValues}"/>
</ContextMenu>
</Border.ContextMenu>