Hi,
I'm using the RadPropertyGrid to show the properties of ExpandoObject with AutoGeneratePropertyDefinitions=true. The ExpandoObject has two nested properties. The first one is based on a public class with some public properties, the other is a second ExpandoObject. When I run the code the PropertyGrid shows the two nested properties as expected (i.e. they are collapsed).
When I expand the nested properties based on the class by clicking the expand-button (plus-sign in front of the nested propertie's name) the class' properties are shown as expected (see screenshot).
When I click the expand-button to expand the nested properties based on the second ExpandoObject the following exception is thrown:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Core.dll
Additional information: Property path is not valid. 'System.Dynamic.ExpandoObject+MetaExpando' does not have a public property named 'X'.
What can I do to solve this problem? I'm using the latest version "2016.3.194 (Dev)" of UI for WPF. Thank you for your help.
Best regards
Christian
P.S. The problem can be reproduced using the following XAML and code
<
Window
x:Class
=
"TelerikWpfApp2.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:propertyGrid
=
"clr-namespace:Telerik.Windows.Controls.Data.PropertyGrid;assembly=Telerik.Windows.Controls.Data"
Title
=
"RadPropertyGrid with nested properties based on ExpandoObject"
Height
=
"350"
Width
=
"508.828"
>
<
StackPanel
>
<
telerik:RadPropertyGrid
x:Name
=
"MyPropertyGrid"
NestedPropertiesVisibility
=
"Visible"
/>
</
StackPanel
>
</
Window
>
using
System;
using
System.Windows;
using
System.Dynamic;
namespace
TelerikWpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
FillPropertyGrid();
}
private
void
FillPropertyGrid()
{
dynamic item =
new
ExpandoObject();
dynamic nestedPropertyBasedOnExpando =
new
ExpandoObject();
nestedPropertyBasedOnExpando.X = 1.0;
nestedPropertyBasedOnExpando.Y = 2.0;
item.NestedPropertyBasedOnClass =
new
Point(3.0, 4.0);
item.NestedPropertyBasedOnExpando = nestedPropertyBasedOnExpando;
// if the following propeties are added then no exception is thrown;
// but nestedProperty1.X and item.X are bound to each other!
// item.X = 0.0;
// item.Y = 0.0;
MyPropertyGrid.Item = item;
}
}
}