Skip to content

Commit c584c39

Browse files
authored
Update README.md
1 parent 4a1de43 commit c584c39

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
# Filtering-the-property-items-of-PropertyGrid-through-attributes
2-
Filtering properties of WPF PropertyGrid through event handling is a powerful technique that allows developers to dynamically control which properties are displayed in the PropertyGrid at runtime. This is particularly useful in scenarios where the visibility of certain properties depends on user interactions, application state, or specific business logic. By leveraging events such as PropertyFilterChanged or custom logic tied to UI triggers, developers can intercept the property rendering process and apply filters based on type, category, name, or custom attributes. For example, you might want to hide advanced settings from novice users or show additional configuration options only when a checkbox is selected. This dynamic filtering enhances user experience by keeping the interface clean and relevant. Implementing this typically involves subscribing to the appropriate event, evaluating the property metadata, and modifying the property list accordingly. WPF’s extensibility makes it possible to integrate such behavior seamlessly into MVVM architectures, ensuring maintainability and scalability.
1+
# Filtering Property Items of Syncfusion WPF PropertyGrid Through Attributes
2+
## Overview
3+
The Syncfusion WPF PropertyGrid control allows developers to filter or hide specific properties using standard .NET attributes. This approach is ideal when you want to statically control which properties are visible in the PropertyGrid without writing additional event-handling logic.
4+
5+
## Why Use Attribute-Based Filtering?
6+
Attribute-based filtering is:
7+
- **Declarative**: You define visibility directly in the model class.
8+
- **Simple**: No need for runtime logic or event subscriptions.
9+
- **Maintainable**: Easy to manage and understand in large codebases.
10+
11+
## Supported Attributes
12+
### 1. [Browsable(false)]
13+
This attribute hides the property from the PropertyGrid.
14+
15+
```C#
16+
using System.ComponentModel;
17+
18+
public class Employee
19+
{
20+
public string Name { get; set; }
21+
22+
[Browsable(false)]
23+
public string InternalCode { get; set; }
24+
25+
public int Age { get; set; }
26+
}
27+
```
28+
29+
### 2. [Bindable(false)]
30+
This also hides the property from the PropertyGrid. It functions similarly to [Browsable(false)].
31+
```C#
32+
using System.ComponentModel;
33+
34+
public class Employee
35+
{
36+
public string Name { get; set; }
37+
38+
[Bindable(false)]
39+
public string SecretKey { get; set; }
40+
}
41+
```

0 commit comments

Comments
 (0)