1

I have a listview, when the mouse passes over the items and gives clicking on them, change color. but when the user clicks on an item and it changes color and the user then clicks on another item, the item previously clicked back to its normal color. How to make so that when the user clicks on an item, other items not previously clicked on return to their normal color. As for the user to click on an item a second time, the item returns to its normal color. Xaml code file of eventons are as follows:

 <EventTrigger RoutedEvent="Border.MouseEnter" >
                            <BeginStoryboard>
                                <Storyboard TargetProperty="(Border.Background).(SolidColorBrush.Color)" >
                                    <ColorAnimation  To="#6990EE90" Duration="0:0:0.3" Storyboard.TargetName="border"  />

                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Border.MouseLeave" >
                            <BeginStoryboard>
                                <Storyboard TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                    <ColorAnimation  To="Transparent" Duration="0:0:0.3" Storyboard.TargetName="border"  />
2
  • Set SelectionMode to Multiple Commented Dec 18, 2015 at 1:24
  • can you put your complete xaml code for your list? Commented Dec 18, 2015 at 2:09

1 Answer 1

1

You need not to do any separate coding or write any trigger for that, just give SelectionMode=Multiple or else you can give SelectionMode=Extended.

ie.,

<ListView SelectionMode="Extended">
//Definition comes here 
</ListView>

The difference between these two is that[Reference]:

SelectionMode=Extended: The user can select multiple consecutive items while holding down the SHIFT key.

SelectionMode=Multiple : The user can select multiple items without holding down a modifier key.

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

2 Comments

I turned another drawback, I have a method that when the user clicks on an item of listview item captures, the method ListViewItem_PreviewMouseLeftButtonDown, I before setting the ListView in SelectionMode="Multiple" it worked. but now that establishes SelectionMode="Multiple", does not work, does not capture the item clicked by the user. What can I do?
Try SelectionMode=Extended

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.