Skip to content

Commit

Permalink
fix: Apply proper TreeViewItem indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Sep 11, 2020
1 parent a60a0af commit a437d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:local="using:Microsoft.UI.Xaml.Controls"
xmlns:media="using:Microsoft.UI.Xaml.Media">
<!-- TODO WinUI: Base on ListViewItemRevealStyle when implemented -->
<Style x:Key="MUX_TreeViewItemStyle" TargetType="local:TreeViewItem">
<Style x:Key="MUX_TreeViewItemStyle" TargetType="local:TreeViewItem" BasedOn="{StaticResource ListViewItemExpanded}">
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{ThemeResource TreeViewItemBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource TreeViewItemBorderBrush}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ protected override void PrepareContainerForItemOverride(DependencyObject element
templateSettings.ExpandedGlyphVisibility = itemNode.IsExpanded ? Visibility.Visible : Visibility.Collapsed;
templateSettings.CollapsedGlyphVisibility = !itemNode.IsExpanded ? Visibility.Visible : Visibility.Collapsed;

// Uno Workaround - waiting for #1453, remove this when fixed
var treeViewItem = itemContainer;
var targetNode = NodeFromContainer(treeViewItem);
treeViewItem.UpdateIndentation(targetNode.Depth);
treeViewItem.UpdateSelectionVisual(targetNode.SelectionState);
// workaround end

base.PrepareContainerForItemOverride(element, item);

if (selectionState != itemNode.SelectionState)
Expand All @@ -351,7 +358,7 @@ protected override void PrepareContainerForItemOverride(DependencyObject element

protected override DependencyObject GetContainerForItemOverride()
{
var targetItem = new TreeViewItem();
var targetItem = new TreeViewItem() { IsGeneratedContainer = true };
return targetItem;
}

Expand Down

0 comments on commit a437d2f

Please sign in to comment.