0

I have a TextBox inside my ListView. When I click on the textview, the SelectionChanged event of ListView is not fired.

Is there a way to fire that, so that the ListView item is selected?

2 Answers 2

1

Despite the fact that you have not asked a good question, I think I understand your problem. I'm assuming that when you said textview, you actually meant Textbox and that your problem is that your ListViewItem is not changed to the item that contains the TextBox that you clicked on. If this is so, then adding this Style should do the trick:

<Style x:Key="ListViewItemSelectionStyle" TargetType="{x:Type ListViewItem}">
    <Style.Triggers>
        <Trigger Property="IsKeyboardFocusWithin" Value="True">
            <Setter Property="IsSelected" Value="True" />
        </Trigger>
        <Trigger Property="IsKeyboardFocusWithin" Value="False">
            <Setter Property="IsSelected" Value="True" />
        </Trigger>
    </Style.Triggers>
</Style>

While it looks strange, the second part is to ensure that the item remains selected after it loses KeyboardFocus.

Sign up to request clarification or add additional context in comments.

Comments

0

You haven't provided any code, but at a guess, you haven't handled the event:

<ListView SelectionChanged="MyEventHandler" ...
</ListView>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.