bodong.Avalonia.PropertyGrid 0.10.19.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package bodong.Avalonia.PropertyGrid --version 0.10.19.3                
NuGet\Install-Package bodong.Avalonia.PropertyGrid -Version 0.10.19.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="0.10.19.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add bodong.Avalonia.PropertyGrid --version 0.10.19.3                
#r "nuget: bodong.Avalonia.PropertyGrid, 0.10.19.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install bodong.Avalonia.PropertyGrid as a Cake Addin
#addin nuget:?package=bodong.Avalonia.PropertyGrid&version=0.10.19.3

// Install bodong.Avalonia.PropertyGrid as a Cake Tool
#tool nuget:?package=bodong.Avalonia.PropertyGrid&version=0.10.19.3                

Avalonia.PropertyGrid

This is a PropertyGrid implementation for Avalonia, you can use it in Avalonia Applications.
Its main features are:

  • Support automatically analyze object properties and display, like WinForms's PropertyGrid
  • Support simultaneous editing of multiple objects (some types of properties cannot support simultaneous editing of multiple objects)
  • Support ICustomTypeDescriptor
  • Support data verification. You can directly throw an exception in the property setter to report a data error, and of course you can add validation to the property based on System.ComponentModel.DataAnnotations. The system also automatically analyzes and processes these checks.
  • Supports two display modes: category-based and alphabetical sorting
  • Supports text filtering, regular expression filtering, and supports ignoring case settings
  • Support data automatic reloading, when data is modified from the outside or other PropertyGrid, it will automatically refresh the data, but the target object needs to implement the interface INotifyPropertyChanged
  • Support automatic expansion of sub-objects, but need to mark attributes [TypeConverter(typeof(ExpandableObjectConverter))]
  • Support to adjust the width of the property name and property value by dragging and dropping, and the optimal width will be automatically calculated when the SelectObject is set for the first time
  • Supports dynamic visibility, that is, whether a property is visible can be dynamically determined by another property's value
  • The extension is very simple, you can use very simple code at any time to make the PropertyGrid support the type of editing that is not originally supported. The system has built-in support for some common property editing, but it is not complete, so when you need to edit a specific object through a special control, you need to expand it yourself, and this step is very simple.
  • Support array editing, support dynamic addition and deletion. Arrays of objects of any type are supported. The array mentioned here is just a BindingList<> object

How To Use

Use the source code of this warehouse directly or add packages from nuget(https://www.nuget.org/packages/bodong.Avalonia.PropertyGrid).
Then add PropertyGrid to your project, and bind the object to be displayed and edited to the SelectObject property. If you want to bind multiple objects, just bind IEnumerable<T> directly

Samples

Basic View You can clone this project, and open Avalonia.PropertyGrid.sln, build it and run Avalonia.PropertyGrid.Samples, you can view this.

Basic

This page shows the basic functions of PropertyGrid, including the display of various properties and the default editor, etc.

Views

Views You can see the PropertyGrid with filtering and grouping by category turned off. Just change Properties:

<StackPanel Orientation="Vertical">
    <TextBlock>Default View</TextBlock>
    <pgc:PropertyGrid Margin="4" SelectedObject="{Binding simpleObject}"></pgc:PropertyGrid>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2">
    <TextBlock>Not Allow Filter</TextBlock>
    <pgc:PropertyGrid Margin="4" AllowFilter="False" SelectedObject="{Binding simpleObject}"></pgc:PropertyGrid>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="4">
    <TextBlock>Not Allow Filter And No Categories</TextBlock>
    <pgc:PropertyGrid Margin="4" AllowFilter="False" ShowStyle="Alphabetic" SelectedObject="{Binding simpleObject}"></pgc:PropertyGrid>
</StackPanel>

DataSync

Here you can verify data changes and auto-reload functionality.

MultiObjects

You can verify the function of multi-object editing here. Note:
some properties do not support editing multiple objects at the same time.

CustomObject

CustomObject Here shows how to create a custom object based on ICustomTypeDescriptor.

Custom Cell Edit

CustomCellEdit By default, PropertyGrid uses CheckBox to edit Boolean data, here shows how to use ToggleSwitch to edit Boolean data in a simple way, and how to make this function only effective locally without affecting the whole. This is the Custom Cell Edit's Codes:

    // create a child property
    public class ToggleSwitchExtensionPropertyGrid : Controls.PropertyGrid
    {
        static ToggleSwitchExtensionPropertyGrid()
        {
            FactoryTemplates.AddFactory(new ToggleSwitchCellEditFactory());
        }
    }

    class ToggleSwitchCellEditFactory : AbstractCellEditFactory
    {
        // make this extend factor only effect on ToggleSwitchExtensionPropertyGrid
        public override bool Accept(object accessToken)
        {
            return accessToken is ToggleSwitchExtensionPropertyGrid;
        }

        public override Control HandleNewProperty(object target, PropertyDescriptor propertyDescriptor)
        {
            if (propertyDescriptor.PropertyType != typeof(bool))
            {
                return null;
            }

            ToggleSwitch control = new ToggleSwitch();
            control.Checked += (s, e) => { SetAndRaise(control, propertyDescriptor, target, true); };
            control.Unchecked += (s, e) => { SetAndRaise(control, propertyDescriptor, target, false); };

            return control;
        }

        public override bool HandlePropertyChanged(object target, PropertyDescriptor propertyDescriptor, Control control)
        {
            if (propertyDescriptor.PropertyType != typeof(bool))
            {
                return false;
            }

            ValidateProperty(control, propertyDescriptor, target);

            if (control is ToggleSwitch ts)
            {
                ts.IsChecked = (bool)propertyDescriptor.GetValue(target);

                return true;
            }

            return false;
        }
    }

Dynamic Visibility

DynamicVisibility PropertyGrid supports dynamic visibility adjustment of properties. For example, you can let users see a certain property only when a certain property is True, otherwise it is invisible.
In this example, you can check IsShowPath first, then set the Platform to Unix, and then enter something in UnixVersion, and you will see the unixLoginInfo field.

    public class DynamicVisibilityObject : ReactiveObject
    {
        [ConditionTarget]
        public bool IsShowPath { get; set; } = true;

        [VisibilityPropertyCondition(nameof(IsShowPath), true)]
        [PathBrowsable(Filters = "Image Files(*.jpg;*.png;*.bmp;*.tag)|*.jpg;*.png;*.bmp;*.tag")]
        public string Path { get; set; } = "";

        [ConditionTarget]
        public PlatformID Platform { get; set; } = PlatformID.Win32NT;

        [VisibilityPropertyCondition(nameof(Platform), PlatformID.Unix)]
        [ConditionTarget]
        public string UnixVersion { get; set; } = "";

        // show more complex conditions...
        [Browsable(false)]
        [DependsOnProperty(nameof(IsShowPath), nameof(Platform), nameof(UnixVersion))]
        [ConditionTarget]
        public bool IsShowUnixLoginInfo => IsShowPath && Platform == PlatformID.Unix && UnixVersion.IsNotNullOrEmpty();

        [VisibilityPropertyCondition(nameof(IsShowUnixLoginInfo), true)]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public LoginInfo unixLogInInfo { get; set; } = new LoginInfo();
    }

To do this, you only need to mark the property with a custom Attribute. If you need to implement your own rules, just implement your own rules from AbstractVisiblityConditionAttribute.
One thing to pay special attention to is that any property that needs to be used as a visibility condition for other properties needs to be marked with [ConditionTarget].
The purpose is to let PropertyGrid know that when this property changes, it needs to notify the upper layer to refresh the visibility information.

Avalonia.PropertyGrid.NugetSamples

This example shows how to use PropertyGrid through the Nuget package. Its content is similar to the Sample that directly uses the source code, and it can also be used as a case for learning how to use it.

My Blog: https://www.cnblogs.com/bodong
如果你来自中国或者认识中文,可以在这里获取更多相关信息:
https://www.cnblogs.com/bodong/p/17342817.html

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on bodong.Avalonia.PropertyGrid:

Package Downloads
Spice86

Reverse engineer and rewrite real mode DOS programs

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on bodong.Avalonia.PropertyGrid:

Repository Stars
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
TEdit/Terraria-Map-Editor
TEdit - Terraria Map Editor - TEdit is a stand alone, open source map editor for Terraria. It lets you edit maps just like (almost) paint! It also lets you change world settings (time, bosses downed etc), edit chests and change sign, make epic dungeons, castles, cities, and add rewards for your adventurers!
OpenRakis/Spice86
Reverse engineer and rewrite real mode DOS programs!
bodong1987/Avalonia.PropertyGrid
A property edit control in Avalonia like DevExpress's PropertyGridControl.
Titlehhhh/Minecraft-Holy-Client
A high-performance platform for running Minecraft stress-test bots written in C#.
Version Downloads Last updated
11.1.4.2 579 10/21/2024
11.1.4.1 137 10/18/2024
11.1.1.1 3,151 7/30/2024
11.0.10.1 2,276 6/3/2024
11.0.6.3 6,673 1/4/2024 11.0.6.3 is deprecated because it is no longer maintained and has critical bugs.
11.0.6.2 179 1/4/2024 11.0.6.2 is deprecated because it is no longer maintained and has critical bugs.
11.0.6.1 736 12/19/2023 11.0.6.1 is deprecated because it is no longer maintained and has critical bugs.
11.0.5.1 1,305 11/29/2023 11.0.5.1 is deprecated because it is no longer maintained and has critical bugs.
11.0.4.1 2,647 9/15/2023 11.0.4.1 is deprecated because it is no longer maintained and has critical bugs.
11.0.4 306 9/14/2023 11.0.4 is deprecated because it is no longer maintained and has critical bugs.
11.0.1.6 915 8/28/2023 11.0.1.6 is deprecated because it is no longer maintained.
11.0.1.5 316 8/15/2023 11.0.1.5 is deprecated because it is no longer maintained.
11.0.1.4 230 8/8/2023 11.0.1.4 is deprecated because it is no longer maintained.
11.0.1.3 262 7/27/2023 11.0.1.3 is deprecated because it is no longer maintained.
11.0.1.2 199 7/27/2023 11.0.1.2 is deprecated because it is no longer maintained.
11.0.1.1 220 7/26/2023 11.0.1.1 is deprecated because it is no longer maintained.
11.0.0.7 244 7/26/2023 11.0.0.7 is deprecated because it is no longer maintained.
11.0.0.6 209 7/26/2023 11.0.0.6 is deprecated because it is no longer maintained.
11.0.0.5 192 7/26/2023 11.0.0.5 is deprecated because it is no longer maintained.
11.0.0.4 207 7/25/2023 11.0.0.4 is deprecated because it is no longer maintained.
11.0.0.3 266 7/24/2023 11.0.0.3 is deprecated because it is no longer maintained.
11.0.0.2 219 7/24/2023 11.0.0.2 is deprecated because it is no longer maintained.
11.0.0.1 260 7/12/2023 11.0.0.1 is deprecated because it is no longer maintained.
11.0.0 264 7/11/2023 11.0.0 is deprecated because it is no longer maintained.
11.0.0-rc2.2.1 121 7/3/2023 11.0.0-rc2.2.1 is deprecated because it is no longer maintained.
11.0.0-rc1.1.4 119 7/3/2023 11.0.0-rc1.1.4 is deprecated because it is no longer maintained.
11.0.0-rc1.1.3 112 6/26/2023 11.0.0-rc1.1.3 is deprecated because it is no longer maintained.
11.0.0-rc1.1.2 106 6/25/2023 11.0.0-rc1.1.2 is deprecated because it is no longer maintained.
11.0.0-rc1.1.1 109 6/20/2023 11.0.0-rc1.1.1 is deprecated because it is no longer maintained.
11.0.0-rc1.1 130 6/8/2023 11.0.0-rc1.1 is deprecated because it is no longer maintained.
0.10.21.2 270 6/8/2023 0.10.21.2 is deprecated because it is no longer maintained.
0.10.21.1 198 6/8/2023 0.10.21.1 is deprecated because it is no longer maintained.
0.10.19.6 189 6/8/2023 0.10.19.6 is deprecated because it is no longer maintained.
0.10.19.5 185 6/8/2023 0.10.19.5 is deprecated because it is no longer maintained.
0.10.19.4 278 4/23/2023 0.10.19.4 is deprecated because it is no longer maintained.
0.10.19.3 219 4/22/2023 0.10.19.3 is deprecated because it is no longer maintained.
0.10.19.2 210 4/22/2023 0.10.19.2 is deprecated because it is no longer maintained.
0.10.19.1 235 4/22/2023 0.10.19.1 is deprecated because it is no longer maintained.