I define the PropertyDefinitions in the order in which I want them in in XAML, but the groups don't display in either alphabetical or
the order I define them.
How can I fix this in XAML or code-behind?
Alan
11 Answers, 1 is accepted
Will it be possible to clarify a bit what is your exact requirement - do you want to sort the groups or the property definitions inside them ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

I can already use the OrderIndex to sort the items within the groups.
Is there OrderIndex for groups as well?
Alan
You can try specifying the Order attribute of the properties in each group so that their group's order correspond to the required one. I am attaching a sample project illustrating how you can order groups - Group 3, Group 2, Group 1 instead of the default order.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Thanks for this.
Unfortunately I must now create PropertyDefinition in XAML as data-annotations and automatic
property definition creation can't do some other things I want to do.
Is there way in XAML to force the group order?
Thanks,
Alan
You can try setting OrderIndex property of the property definitions. For example:
<
telerik:PropertyDefinition
OrderIndex
=
"0"
/>
All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

That doesn't work as the OrderIndex only specifies the order of property items within a group.
What I need to do is set the order of the groups themselves.
See original question and your reply for more info on what I want to do.
Alan
I might be missing something here, but I managed to get the same behavior as the one with data annotations by setting OrderIndex property of the property definitions,. Could you check the updated sample to verify whether this is the behavior that you require ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
.jpg)
Currently, such functionality cannot be implemented without breaking a lot of the existing features and the way property grid works. The only thing to do is to follow the approach suggested above - to specify the order indices of the property definitions/ properties.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
.jpg)
private
readonly
Dictionary<
string
, PropertyDefinition> _propertyDefinitions =
new
Dictionary<
string
, PropertyDefinition>
{
// common
{
"Name"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Name,GroupName = CommonGrp,OrderIndex = 1}},
{
"DisplayText"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Displaytext,GroupName = CommonGrp,OrderIndex = 2}},
{
"IsRequired"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_IsRequired,GroupName = CommonGrp,OrderIndex = 3}},
{
"RequiredCondition"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_RequiredCondition,GroupName = CommonGrp,OrderIndex = 4}},
{
"IsVisible"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_IsVisible ,GroupName = CommonGrp,OrderIndex = 5}},
{
"VisibleCondition"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_VisibleCondition ,GroupName = CommonGrp,OrderIndex = 6}},
{
"IsReadOnly"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_IsReadOnly ,GroupName = CommonGrp,OrderIndex = 7}},
{
"ReadOnlyCondition"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_ReadOnlyCondition ,GroupName = CommonGrp,OrderIndex = 8}},
{
"ExpressionId"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_ExpressionId ,GroupName = CommonGrp,OrderIndex = 9}},
{
"DefaultValue"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_DefaultValue ,GroupName = CommonGrp,OrderIndex = 10}},
{
"Index"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Index ,GroupName = CommonGrp,OrderIndex = 11}},
// Layout
{
"Height"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Height ,GroupName = LayoutGrp,OrderIndex = 20}},
{
"Width"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Width,GroupName = LayoutGrp,OrderIndex = 21}},
{
"Left"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Left,GroupName = LayoutGrp,OrderIndex = 22}},
{
"Top"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Top,GroupName = LayoutGrp,OrderIndex = 23}},
{
"Alignment"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_Alignment,GroupName = LayoutGrp,OrderIndex = 24}},
{
"LabelWidth"
,
new
PropertyDefinition{DisplayName = Properties.Resources.InputField_LabelWidth,GroupName = LayoutGrp,OrderIndex = 25}},
{
"UseDynamicWidth"
,
new
PropertyDefinition{DisplayName = Properties.Resources.PropertyField_UseDynamicWidth,GroupName = LayoutGrp,OrderIndex = 26}},
{
"Layout"
,
new
PropertyDefinition{DisplayName =
"xLayout"
,GroupName = LayoutGrp,OrderIndex = 27}},
{
"FlowDirection"
,
new
PropertyDefinition{DisplayName = Properties.Resources.GroupBox_FlowDirection,GroupName = LayoutGrp,OrderIndex = 28}},
{
"Multiline"
,
new
PropertyDefinition{DisplayName = Properties.Resources.TextBox_Multiline,GroupName = LayoutGrp,OrderIndex = 29}},
};
As far as I can see, you are setting the order index of the properties, so I am guessing you managed to display them as required. Am I right or am I missing something ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.