Skip to content

Commit 35167df

Browse files
authored
added AP to control the cursor when hovering over a ListBoxItem and made the default cursor the Hand (#3848)
1 parent 3b30b20 commit 35167df

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/MaterialDesignThemes.Wpf/ListBoxItemAssist.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,15 @@ public static void SetShowSelection(DependencyObject element, bool value)
6161
public static readonly DependencyProperty ShowSelectionProperty =
6262
DependencyProperty.RegisterAttached("ShowSelection", typeof(bool), typeof(ListBoxItemAssist), new PropertyMetadata(true));
6363
#endregion
64+
65+
#region Cursor
66+
public static Cursor GetCursor(DependencyObject obj)
67+
=> (Cursor)obj.GetValue(CursorProperty);
68+
69+
public static void SetCursor(DependencyObject obj, Cursor value)
70+
=> obj.SetValue(CursorProperty, value);
71+
72+
public static readonly DependencyProperty CursorProperty =
73+
DependencyProperty.RegisterAttached("Cursor", typeof(Cursor), typeof(ListBoxItemAssist), new PropertyMetadata(Cursors.Hand));
74+
#endregion
6475
}

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ListBox.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
<Setter Property="wpf:ListBoxItemAssist.HoverBackground" Value="{Binding Foreground, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BrushOpacityConverter.Instance}, ConverterParameter=0.1}" />
242242
<Setter Property="wpf:ListBoxItemAssist.SelectedFocusedBackground" Value="{Binding Foreground, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BrushOpacityConverter.Instance}, ConverterParameter=0.18}" />
243243
<Setter Property="wpf:ListBoxItemAssist.SelectedUnfocusedBackground" Value="{Binding Foreground, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BrushOpacityConverter.Instance}, ConverterParameter=0.09}" />
244+
<Setter Property="Cursor" Value="{Binding Path=(wpf:ListBoxItemAssist.Cursor), RelativeSource={RelativeSource AncestorType=ListBox}}"/>
244245
<Setter Property="Template">
245246
<Setter.Value>
246247
<ControlTemplate TargetType="{x:Type ListBoxItem}">
@@ -423,6 +424,7 @@
423424
<Setter Property="Margin" Value="4,2,4,2" />
424425
<Setter Property="Padding" Value="8" />
425426
<Setter Property="SnapsToDevicePixels" Value="True" />
427+
<Setter Property="Cursor" Value="{Binding Path=(wpf:ListBoxItemAssist.Cursor), RelativeSource={RelativeSource AncestorType=ListBox}}"/>
426428
<Setter Property="Template">
427429
<Setter.Value>
428430
<ControlTemplate TargetType="{x:Type ListBoxItem}">

0 commit comments

Comments
 (0)