Skip to content

Commit

Permalink
Adding the ability to disable the expand on double click behavior (#3399
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Keboo authored Dec 2, 2023
1 parent c911f64 commit ecacb44
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion MaterialDesignThemes.Wpf/TreeListViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public int Level
DependencyProperty.Register(nameof(Level), typeof(int), typeof(TreeListViewItem), new PropertyMetadata(0));



public bool DisableExpandOnDoubleClick
{
get => (bool)GetValue(DisableExpandOnDoubleClickProperty);
set => SetValue(DisableExpandOnDoubleClickProperty, value);
}

public static readonly DependencyProperty DisableExpandOnDoubleClickProperty =
DependencyProperty.Register("DisableExpandOnDoubleClick", typeof(bool), typeof(TreeListViewItem), new PropertyMetadata(false));

internal IEnumerable? Children
{
get => (IEnumerable?)GetValue(ChildrenProperty);
Expand Down Expand Up @@ -158,7 +168,7 @@ private void UpdateHasChildren()
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
base.OnMouseDoubleClick(e);
if (e.ChangedButton == MouseButton.Left)
if (!e.Handled && !DisableExpandOnDoubleClick && e.ChangedButton == MouseButton.Left)
{
IsExpanded = !IsExpanded;
}
Expand Down

0 comments on commit ecacb44

Please sign in to comment.