DictionaryDataFactory Example no longer works

Grids for WPF Forum

Posted 4 years ago by Kristoffer
Version: 20.1.1
Platform: .NET 5.0
Environment: Windows 10 (64-bit)

I have some code that is based on the DictionaryDataFactory Example. But this no longer works. I tested the example in sample browser, and it does not seem to work there either. In the sample I'm unable to enter any value in the Value column. In my own example I do not get the + button, and the value just dissapears when it looses focus.

Comments (2)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA


Thanks for letting us know about the sample bug.  Please add this to the AddEntryPropertyModel constructor:

this.ValueType = typeof(string);

That will get the ValueToString back to Value conversion working, which will allow the text entry and "+" button to show up again.  We also will be updating our code for the next build so that line isn't needed in this sample since it will assume if no ValueType is specified, the ValueType is Object, but it's still a best practice to specify the ValueType.

The other issue is that since PropertyModel changed to inherit FrameworkElement in v2020.1 so that data binding could be supported in XAML, it took over the Parent property.  In the AddEntryPropertyModel.AddChild method, change this line to get the IDataModel.Parent instead of FrameworkElement.Parent:

var rootModel = ((IDataModel)this).Parent as IRootModel;

Those two updates should resolve the problem.

Actipro Software Support

Posted 4 years ago by Kristoffer


Thanks for fast reply. The first solution worked, and added back the + sign.

However the second did not. When I changed the line to:

var rootModel = ((IDataModel)this).Parent as IRootModel;

rootModel is set to null.

EDIT: Never mind, got it to work. Thanks!!

[Modified 4 years ago]

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.