Skip to content

Commit 4d8e317

Browse files
committed
start list box assist for quick unselect
1 parent a64f2b8 commit 4d8e317

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
129129
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
130130
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
131+
<Setter Property="materialDesign:ListBoxAssist.IsQuickUnselectEnabled" Value="True" />
131132
<Setter Property="VerticalContentAlignment" Value="Center"/>
132133
<Setter Property="ItemContainerStyle" Value="{StaticResource MaterialDesignToggleListBoxItem}"/>
133134
<Setter Property="ItemsPanel">
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Input;
9+
using System.Windows.Media;
10+
11+
namespace MaterialDesignThemes.Wpf
12+
{
13+
public static class ListBoxAssist
14+
{
15+
static ListBoxAssist()
16+
{
17+
EventManager.RegisterClassHandler(typeof (ListBox), UIElement.PreviewMouseLeftButtonDownEvent,
18+
new MouseButtonEventHandler(Target));
19+
}
20+
21+
private static void Target(object sender, MouseButtonEventArgs mouseButtonEventArgs)
22+
{
23+
Point pt = mouseButtonEventArgs.GetPosition((UIElement)sender);
24+
//VisualTreeHelper.HitTest()
25+
//mouseButtonEventArgs.
26+
}
27+
28+
public static readonly DependencyProperty IsQuickUnselectEnabledProperty = DependencyProperty.RegisterAttached(
29+
"IsQuickUnselectEnabled", typeof(bool), typeof(ListBoxAssist), new FrameworkPropertyMetadata(default(bool)));
30+
31+
public static void SetIsQuickUnselectEnabled(DependencyObject element, bool value)
32+
{
33+
element.SetValue(IsQuickUnselectEnabledProperty, value);
34+
}
35+
36+
public static bool GetIsQuickUnselectEnabled(DependencyObject element)
37+
{
38+
return (bool)element.GetValue(IsQuickUnselectEnabledProperty);
39+
}
40+
}
41+
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
<Compile Include="HintProxyFabric.cs" />
286286
<Compile Include="Icon.cs" />
287287
<Compile Include="IconType.cs" />
288+
<Compile Include="ListBoxAssist.cs" />
288289
<Compile Include="Palette.cs" />
289290
<Compile Include="Transitions\CircleWipe.cs" />
290291
<Compile Include="IHintProxy.cs" />

0 commit comments

Comments
 (0)