You will not be able to set TreeDataGridRow.IsVisible
from Selector
, because (as of now) it is set to true
with LocalValue
priority. In the future pay attention to "Priority" column in Avalonia inspector.
You can set the value with the help of attached behavior.
Here is a solution with behavior:
using Avalonia;using Avalonia.Controls.Primitives;namespace Behaviors;public class TreeDataGridBehavior : AvaloniaObject{ public static readonly AttachedProperty<bool> IsRowVisibleProperty = AvaloniaProperty.RegisterAttached<TreeDataGridBehavior, bool>("IsRowVisible", typeof(TreeDataGridBehavior)); public static void SetIsRowVisible(AvaloniaObject element, bool value) => element.SetValue(IsRowVisibleProperty, value); public static bool GetIsRowVisible(AvaloniaObject element) => element.GetValue(IsRowVisibleProperty); static TreeDataGridBehavior() { IsRowVisibleProperty.Changed.AddClassHandler<TreeDataGridRow, bool>( (row, e) => row.IsVisible = e.NewValue == true); }}
And xaml (define on root element xmlns:bb="clr-namespace:Behaviors"
):
<TreeDataGrid.Styles><Style Selector="TreeDataGridRow"><Setter Property="bb:TreeDataGridBehavior.IsRowVisible" Value="{ReflectionBinding IsVisible}"/></Style></TreeDataGrid.Styles>