bodong.Avalonia.PropertyGrid
0.10.19.3
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
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="0.10.19.3" />
paket add bodong.Avalonia.PropertyGrid --version 0.10.19.3
#r "nuget: bodong.Avalonia.PropertyGrid, 0.10.19.3"
// 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
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
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
Here shows how to create a custom object based on ICustomTypeDescriptor.
Custom Cell Edit
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
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 | Versions 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. |
-
.NETStandard 2.0
- Avalonia (>= 0.10.19)
- Avalonia.Diagnostics (>= 0.10.19)
- Newtonsoft.Json (>= 13.0.3)
- XamlNameReferenceGenerator (>= 1.6.1)
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 | 907 | 10/21/2024 | |
11.1.4.1 | 145 | 10/18/2024 | |
11.1.1.1 | 3,374 | 7/30/2024 | |
11.0.10.1 | 2,287 | 6/3/2024 | |
11.0.6.3 | 6,691 | 1/4/2024 | |
11.0.6.2 | 181 | 1/4/2024 | |
11.0.6.1 | 740 | 12/19/2023 | |
11.0.5.1 | 1,473 | 11/29/2023 | |
11.0.4.1 | 2,655 | 9/15/2023 | |
11.0.4 | 311 | 9/14/2023 | |
11.0.1.6 | 917 | 8/28/2023 | |
11.0.1.5 | 322 | 8/15/2023 | |
11.0.1.4 | 233 | 8/8/2023 | |
11.0.1.3 | 264 | 7/27/2023 | |
11.0.1.2 | 201 | 7/27/2023 | |
11.0.1.1 | 224 | 7/26/2023 | |
11.0.0.7 | 246 | 7/26/2023 | |
11.0.0.6 | 213 | 7/26/2023 | |
11.0.0.5 | 194 | 7/26/2023 | |
11.0.0.4 | 209 | 7/25/2023 | |
11.0.0.3 | 268 | 7/24/2023 | |
11.0.0.2 | 221 | 7/24/2023 | |
11.0.0.1 | 262 | 7/12/2023 | |
11.0.0 | 267 | 7/11/2023 | |
11.0.0-rc2.2.1 | 123 | 7/3/2023 | |
11.0.0-rc1.1.4 | 121 | 7/3/2023 | |
11.0.0-rc1.1.3 | 114 | 6/26/2023 | |
11.0.0-rc1.1.2 | 108 | 6/25/2023 | |
11.0.0-rc1.1.1 | 111 | 6/20/2023 | |
11.0.0-rc1.1 | 132 | 6/8/2023 | |
0.10.21.2 | 274 | 6/8/2023 | |
0.10.21.1 | 202 | 6/8/2023 | |
0.10.19.6 | 193 | 6/8/2023 | |
0.10.19.5 | 187 | 6/8/2023 | |
0.10.19.4 | 279 | 4/23/2023 | |
0.10.19.3 | 221 | 4/22/2023 | |
0.10.19.2 | 211 | 4/22/2023 | |
0.10.19.1 | 238 | 4/22/2023 |