Skip to content

Commit

Permalink
Fixing issues with focus visual style on focus not being resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Keboo committed Oct 24, 2023
1 parent c6c8ac1 commit 1fdce0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,20 @@
<Setter Property="Width" Value="16" />
</Style>

<Style x:Key="MaterialDesignTreeListViewItemFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="MaterialDesignTreeListViewItem" TargetType="{x:Type wpf:TreeListViewItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource MaterialDesignTreeViewItemFocusVisual}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource MaterialDesignTreeListViewItemFocusVisual}" />
<Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type wpf:TreeListView}}}" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Padding" Value="8" />
Expand Down
5 changes: 0 additions & 5 deletions MaterialDesignThemes.Wpf/TreeListViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MaterialDesignThemes.Wpf;

//[TemplatePart(Name = "PART_Header", Type = typeof(TreeListViewItemContentPresenter))]
[System.Diagnostics.DebuggerDisplay("Container for {DataContext}")]
public class TreeListViewItem : ListViewItem
{
Expand All @@ -12,7 +11,6 @@ public TreeListViewItem()

private TreeListView? TreeListView { get; set; }

//TODO: Remove
public IEnumerable<object?> GetChildren() => Children ?? Array.Empty<object?>();

public bool IsExpanded
Expand All @@ -39,7 +37,6 @@ public bool HasItems
set => SetValue(HasItemsProperty, value);
}

// Using a DependencyProperty as the backing store for HasItems. This enables animation, styling, binding, etc...
public static readonly DependencyProperty HasItemsProperty =
DependencyProperty.Register(nameof(HasItems), typeof(bool), typeof(TreeListViewItem), new PropertyMetadata(false));

Expand Down Expand Up @@ -113,7 +110,6 @@ internal void ClearTreeListViewItem(object item, TreeListView treeListView)
TreeListView = null;
}


private void UpdateHasChildren()
{
SetCurrentValue(HasItemsProperty, Children?.Any() == true);
Expand Down Expand Up @@ -151,5 +147,4 @@ protected override void OnKeyDown(KeyEventArgs e)
}
}
}

}

0 comments on commit 1fdce0e

Please sign in to comment.