WPF_ListBox实现单击选中,重复单击取消选中效果(MVVM模式)
- View:
在View中为ListBoxItem设置PreviewMouseLeftButtonDown事件,并为IsSelected属性设置绑定。
<UserControl x:Class="_5_RoutedEventTest.Views.ListBoxTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="ListBox" x:Key="list">
<Setter Property="ItemTemplate">
<Setter.Value>
<D