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
|
Hello. I'm using VisualStudio 2005 TeamEdition. I have created WPF project. There I created class with code: |
|
|
Hmm, I've tried your code in both Visual Studio 2005 and 2008 and I'm not seeing the exception you describe. Can you tell me if you see the same problem in the sample projects? (To build the samples in VS2005, don't click on the Samples link in the Start menu, but instead go to the WPF Property Grid directory, open the Samples folder, and open the Samples2005 solution.) The sample data includes read-write properties as you can see, and you certainly shouldn't need to do anything special to make them work! Given its location, the NullReferenceException you are seeing is one I would usually associate with the 'window' reference being null, but that seems unlikely, and doesn't explain why you see the exception when and only when you define a Set method on your property. Could you check the exception to see if there is an InnerException behind the NullReferenceException, and have a look at the stack trace to see if the original exception site is somewhere else, e.g. within the TestPropGrid constructor? Finally, since I cannot reproduce the problem, could you zip up your test project and send it to me? (Use the Options tab to attach a file to a message.) Perhaps seeing the code in context will help me to figure out what's going on! |
|
|
Hello! Thank you for replying.
First of all I want to say that I've downloaded WpfPropertyGridTrial, but there I can't see Samples2005 solution. I put screen shot named Sample 2005 Problem.gif. So, i've created my own WPF Project due to Mindscape Documentation. (it is in trial ) Exception that throws represented by screenshot Exception.gif Folder PropertyInspectorGridTest contains my solution. There you can see my code. If you will comment set state of the Test property code: public string Test { get { return mTest; } //set { mTest = value; } } after running the application you will see two properties Test and Test1 with values hello and hello1. But if set state of the Test property is clear (not commented), the application throws error. The same thing you can get using Pet class instead of Nop class. Can you help me, please? |
|
|
Screenshot with Exception |
|
|
Screenshot with Sample 2005 problem |
|
|
Hello Ivan. I have the same problem! Can You help me to solve it? |
|
|
Hi Serhiy and Mykhaylo, Thanks for sending the repro case. The problem appears to occur on machines that have .NET Framework 3.0 but do *not* have Service Pack 1. Installing .NET 3.0 SP 1 should cure the problem. You can get this from http://www.microsoft.com/downloads/details.aspx?familyid=EC2CA85D-B255-4425-9E65-1E88A0BDB72A&displaylang=en. Please let me know if you still see the same error after installing SP1. I apologise for the confusing error and the lack of documentation around this in the trial edition. Unfortunately, as I now recall, we added the documentation and samples for .NET 3.0 / VS2005 shortly *after* the launch of v1.0, and you therefore need to get a nightly build to get them. You can get this from http://www.mindscape.co.nz/Products/WpfPropertyGrid/nightlybuilds.aspx (this contains a couple of other bug fixes and enhancements). Apologies for pointing you in the wrong direction. |
|
|
Hello Ivan! Thank you for replying! After installing SP 1.0 for .NetFramework 3.0 it works fine! Thank you! |
|
|
Hi. Thank you very much. Now Property Grid works very good. But I have one more question: earlier I added properties to control using code: TestGrid.SelectedObject = Person.Alice; But now due to my project structure I must dynamically add nodes. foreach (Property prop in myProperties) It works pretty good. But how can I group this nodes? |
|
|
I hope it's the last question :) If I edit node value in the PropertyGridControl, how can I edit prop.Value in myProperties array this time? foreach (Property prop in myProperties) Does PropertyGrid have some events that can help me?
|
|
|
Regardless of whether a node comes from a SelectedObject property, an AddNode call or the ItemsSource dictionary, grouping is accomplished via the usual WPF method of adding a GroupDescription to an ICollectionView. In the case of the WPF Property Grid, the collection view you need to group is PropertyGrid.BindingView.DefaultView. Normally the easiest way to set up grouping is to use the built-in PropertyGroupDescription class. You give this a property name and an IValueConverter. For each object in the collection, WPF gets the value of the named property and passes it to the value converter; the resulting string is the name of the group to put the node into. For the WPF Property Grid, the objects in the collection are PropertyGridRows and you will usually use the Node property. If you need something wilder than this then you can implement your own GroupDescription class. However, given that all of the interesting information about the node is available through the PropertyGridRow.Node property, this shouldn't be necessary in most circumstances. I wrote a post about this with quite a few examples at http://www.mindscape.co.nz/blog/index.php/2008/01/27/sorting-and-grouping-in-the-wpf-property-grid/ which should get you started. They're written in terms of SelectedObject and ItemsSource but nodes that come from AddNode will work exactly the same way. |
|
|
The property grid does not currently raise events when a value is edited: it just propagates the change back to the node. You can examine addedNode.Value to get the current value. (So you will need to keep the added nodes in a list or dictionary or something.) Thinking about it, it would be reasonable for Node to implement INotifyPropertyChanged, so you could listen for the PropertyChanged event on addedNode, and/or for the grid to provide a PropertyValueChanged event. I'll add these to the wish list. |
|
|
I just downloaded the trial to see if I could just replace the Windows form in my wpf app. The website claims that it's a "Drop-in replacement for the Windows Forms property grid." I dropped it in. No PropertyValueChanged event. Is there a workaround? |
|
|
Hook PropertyChanged on the selected object. We don't automatically forward this to a PropertyValueChanged event on the WPF grid because we feel it's more idiomatic in WPF to react to changes in the underlying object rather than to events on a control, but we'd be happy to look at adding this if there's a specific scenario for it, or if you're making sufficient use of the event that it's critical for compatibility. |
|