LOGIN    REGISTER    YOUR CART

homepage
VisualHint's blog
2022
May25

Fluent API updated

So far, you were able to configure a category with a specific call, and configure child properties this way:

.ForCategory("Credentials", category => category.Comment = "my comment")
.ForProperty(x => x.Username, config => config
    .Category("Credentials", 1)
    .Id(1000)
)

As you can see the calls are at the same level. The property definition had to mention the parent category in order for, let's say, set a sorting index. This kind of mimics the way attributes work. You can attach a CategoryAttribute to a property to set a category sorting index. Obviously this is not very intuitive when using a fluent API. Therefore, I added a new way to define categories and properties and this now displays as a 2-levels hierarchical tree:

.ForCategory("Credentials", config => config
    .Sorted(1)
    .Comment("my comment")

    .ForProperty(x => x.Username, config => config
        .Id(1000)
    )

Note that these methods are also available inside ForCategory to configure a category:

  • Sorted to set a sorting index.
  • Comment to add a description.
  • ImageIndex to add an icon on the left of the category label.
  • ValueText to set a secondary text on the right side of the category label.

That way, this is clear that you define some settings for a category and then for its child properties.
This is in version 4.0.2 and ready for you to enjoy.