0

I have a listbox populate with controls , the control is populated with textboxes and comboboxes. I need to select the underlying listitem when i edit the textbox and select in the combos. Cant seem to find the solutio. Anyone?

    <ListBox.ItemTemplate>
        <DataTemplate>
            <Controls:ComponentEditItem Background="Transparent"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
H.B.
  • 166,899
  • 29
  • 327
  • 400
klashagelqvist
  • 1,251
  • 2
  • 26
  • 52

1 Answers1

0

You can add an EventTrigger that selects underlying ListBoxItem when one of its controls is focused. Something like this:

<ListBox.ItemTemplate>
    <DataTemplate>
        <Controls:ComponentEditItem Background="Transparent">
             <Controls:ComponentEditItem.Triggers>
                  <EventTrigger RoutedEvent="GotFocus">
                        <BeginStoryboard>
                            <Storyboard>
                                 <BooleanAnimationUsingKeyFrames Duration="00:00:00" Storyboard.Target="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Storyboard.TargetProperty="IsSelected">
                                      <DiscreteBooleanKeyFrame Value="True" />
                                 </BooleanAnimationUsingKeyFrames>
                             </Storyboard>
                        </BeginStoryboard>
                   </EventTrigger>
             </Controls:ComponentEditItem.Triggers>
       </Controls:ComponentEditItem>
    </DataTemplate>
</ListBox.ItemTemplate>
icebat
  • 4,696
  • 4
  • 22
  • 36