OutGridTree.Window/Converters/IsLeafConverter.cs
+19
-0
diff --git a/OutGridTree.Window/Converters/IsLeafConverter.cs b/OutGridTree.Window/Converters/IsLeafConverter.cs
new file mode 100644
index 0000000..81ca284
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Management.Automation;
using Avalonia.Data.Converters;
namespace OutGridTree.Window.Converters;
internal sealed class IsLeafConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value switch
{
PSObject => false,
_ => true,
};
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
OutGridTree.Window/Converters/PsObjectPropertiesConverter.cs
+19
-0
diff --git a/OutGridTree.Window/Converters/PsObjectPropertiesConverter.cs b/OutGridTree.Window/Converters/PsObjectPropertiesConverter.cs
new file mode 100644
index 0000000..61f7d1f
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Management.Automation;
using Avalonia.Data.Converters;
namespace OutGridTree.Window.Converters;
internal sealed class PsObjectPropertiesConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value switch
{
PSObject o => o.Properties,
_ => null,
};
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
OutGridTree.Window/MainWindow.axaml
+28
-1
diff --git a/OutGridTree.Window/MainWindow.axaml b/OutGridTree.Window/MainWindow.axaml
index 00f0a64..9b3204c 100644
@@ -2,10 +2,37 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="clr-namespace:OutGridTree.Window.Converters"
xmlns:ps="clr-namespace:System.Management.Automation;assembly=System.Management.Automation"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="OutGridTree.Window.MainWindow"
Title="Out-GridTree">
<Window.Resources>
<c:IsLeafConverter x:Key="isLeafConverter"/>
<c:PsObjectPropertiesConverter x:Key="psObjectPropertiesConverter"/>
</Window.Resources>
<DataGrid Name="Table" AutoGenerateColumns="False" IsReadOnly="True"
GridLinesVisibility="All" BorderThickness="1"
CanUserSortColumns="True" CanUserReorderColumns="True" CanUserResizeColumns="True" />
SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected"
CanUserSortColumns="True" CanUserReorderColumns="True" CanUserResizeColumns="True">
<DataGrid.RowDetailsTemplate>
<DataTemplate x:DataType="{x:Type ps:PSObject}">
<TreeView ItemsSource="{Binding Properties}">
<TreeView.ItemTemplate>
<TreeDataTemplate x:DataType="{x:Type ps:PSPropertyInfo}" ItemsSource="{Binding Value, Converter={StaticResource psObjectPropertiesConverter}}">
<Grid ColumnDefinitions="Auto,Auto" ColumnSpacing="10">
<TextBlock Text="{Binding Name}" Padding="2" />
<TextBox Text="{Binding Value}"
Grid.Column="1"
IsVisible="{Binding $parent.DataContext.Value, Converter={StaticResource isLeafConverter}}"
IsReadOnly="True"
BorderBrush="{x:Null}"
Padding="5,2" />
</Grid>
</TreeDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Window>
docs/screenshot.png
+0
-0
diff --git a/docs/screenshot.png b/docs/screenshot.png
index 1ec61c0..3567046 100644
Binary files a/docs/screenshot.png and b/docs/screenshot.png differ