This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have the following templates defined for my property grid: <DataTemplate x:Key="PropertyGridReadOnlyCellTemplate"> <Style x:Key="ReadOnlyPoppyGrid" TargetType="{x:Type ms:PropertyGrid}"> The class bound to this property implements INotifyPropertyChanged. However, when a property's source changes, the property grid does not immediately update. If, I use the default template, that uses textboxes instead of textblocks for the Value of each property node, grid is updated when property source changes. Any suggestions on how to resolve this using my templates. |
|
|
Bind to Value rather than Node.Value. Node should generally be used only for property metadata; its Value property should be avoided because it is not settable, is not strongly typed, and does not raise property change notifications. (We realise the existence of a Node.Value property is confusing; in retrospect it should have been a GetValue method instead.) |
|
|
Thanks for the response, but if I bind to Value rather than Node.Value, I property values are no longer displayed. |
|
|
Ivan, I made the following change <DataTemplate x:Key="PropertyGridReadOnlyCellTemplate"> as suggested but then property values are no longer displayed, which makes sense if the DataTemplate is being applied onto a Mindscape.WpfPropertyGrid.PropertyGridRow instance. |
|
|
Oops, sorry, I misread your grid style and thought you were inserting this via the Editors collection rather than inserting it directly as the CellTemplate of the GridViewColumn. You're right, my proposed "fix" won't work in that case, because it is indeed binding to a PropertyGridRow. I don't think there's a way around this with your existing template. You need to participate in the editor system in order for the grid to wire up all the notifications. So I would suggest your second GridViewColumn delegate template selection to the grid's EditorSelector in the normal way. You then plumb in your data template by setting it to be the editor for everything: <!-- in property grid template --> <GridViewColumn CellTemplateSelector="{Binding EditorSelector, RelativeSource={RelativeSource AncestorType={x:Type ms:PropertyGrid}}}" /> <!-- in property grid instantiation --> <ms:PropertyGrid.Editors> // in code public class EverythingEditor : ObjectWrappingEditor { (See http://www.mindscape.co.nz/blog/index.php/2008/04/30/smart-editor-declarations-in-the-wpf-property-grid/ for more info about this pattern.) Your data template will now be receiving an ObjectWrapper<T> and can access its Value property, which does raise notifications and therefore enables the template to update as other code changes the value. |
|
|
Ivan, thanks again for the length response. Did all you suggested but still no notification changes when a property 's source changes. Here is my modified source: <!-- instance --> <ms:PropertyGrid <!-- grid style --> <Style x:Key="ReadOnlyPoppyGrid" TargetType="{x:Type ms:PropertyGrid}">
<!-- data template --> <DataTemplate x:Key="PropertyGridReadOnlyCellTemplate">
namespace ControlsLibrary.wpf.Utility
anything i could have missed? Thanks again,
Klaus |
|
|
Hmm, that looks okay. Is it possible for you to create a small complete project that replicates the problem that you can post for us to look at? You can attach a zip file via the Options tab or mail it to ivan @ the obvious domain name (please remove all binaries first). This will make it a bit easier for us to figure out the problem. Thanks! |
|
|
Ivan, someone changes are now being updated on the UI even though I have made absolutely no changes. Strange but true. So this issue can be considered resolved for now. Thanks again for the help. |
|