We are evaluating the PropertyGrid control and have a few questions.
1. When using Nested Properties, I am overriding ToString to display the child property values in the parent. However how do I get this string to update when the child properties are updated?
2. Is there a way to conditionally disable properties based on the values of other properties?
3. When using the Editor attribute with the EditorStyle.Modal option, is there a way to control the start position of the modal?
5 Answers, 1 is accepted
Let me go straight to your questions:
1. I would suggest to check this forum thread where this question has been already discussed - https://www.telerik.com/forums/parent-property-name-with-nested-properties-not-updating
2. Yes, you can tell which property definition to be ReadOnly by binding its IsReadOnly property as demonstrated in the Read Only PropertyDefinition help article. Please note that the editor will look like disabled when set the property to True, so it should works for your scenario.
3. I am afraid the there is no API for controlling the position of the window. This is why I logged a feature request in our feedback portal. Here is the public item. You can follow it in order to track its progress.
If you need further questions do not hesitate to contact us again.
I am happy to inform you that we have implemented the feature request. Now, you can control the position of the window by setting the new WindowLeft and WindowTop properties of the ModalEditor control. Please note that, you will also have to change the WindowStartupLocation property of the ModalEditor control to Manual. You can set these properties by using a simple style like the following:
The new feature is released with our latest internal build. Please feel free to share your feedback on this feature.
Thanks for your reply!
I haven't had much luck getting 1 and 2 to work. Is it possible to do these without declaring the property definition in the XAML? I've attached a sample solution for what im trying to achieve. Basically i want the NestedProperty ToString() value to update whenever one of its properties are updated. Additionally under Nested Property, I would like NestedA, NestedB and NestedC to only be enabled when IsSelected is ticked. Are you able to show me how to achieve these two things? (preferably not declaring properties in the xaml)
Also, thanks for implementing 3 as a feature request! :)
I have 1 working now, but still need help getting 2 to work without declaring the property definitions in the XAML. If you could let me know if this is possible that would be great!
If you do not have XAML defined property definitions you can use the PropertyGrid's AutoGeneratingPropertyDefinition event in order to modify each definition. I have attached a sample project which demonstrates how to bind PropertyDefinition's IsReadOnly property to a property of your ViewModel. The same approach could be used if you want to bind the IsReadOnly to a property of the PropertyGrid's Item. Please use the ReadOnlyPropertyDefinition_WPF.proj file.
If you have other questions do not hesitate to contact me again.