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've purchased WPFPropertyGrid and am running through all the samples to familiarize myself with the API, but I'm having problems with 07_ImprovedErrorHandling.xaml. When I open it in the editor I get an Unhandled Exception message which says: 'ErrorTemplate' property cannot be data-bound. Parameter name: dp Any idea what's broken? I'm using VS2008 and building the sample exactly as it appears in the Samples folder (after fixing the broken reference to Mindscape.WpfPropertyGrid). Thanks, Kevin Donn |
|
|
Hello Kevin, Not sure what's going on here as I haven't been able to reproduce it -- I have installed the latest nightly build and launched the Samples solution from the Start menu, but I don't get a broken reference to the property grid, and I don't see the data binding error you're running into. I assume you mean this error is happening at design time, not run time, is that correct? (I don't get an error in either case, but I want to be sure I'm looking in the right place!) If so, this may be a VS2008 issue -- the WPF visual designer is notoriously unreliable. If you don't have VS2008 SP1, then try installing that as it includes some fixes to the designer -- under SP1 the 07_ImprovingErrorHandling.xaml page comes up without errors for me in both the XAML view and the visual designer. Did you copy the samples to another directory before building them? It shouldn't make any difference to the designer, but I guess it would explain the broken reference to the property grid DLL... If it helps, the ErrorTemplate setup is shown in ErrorHandling.xaml, line 52. The error message is doubly puzzling because we don't actually try to databind the ErrorTemplate -- it appears only in a style Setter... |
|
|
Yes, I do mean it's happening at design time, but in a related note I've been unsuccessful at making the error template ever display at run time on this Page 7 of the Customization Walkthrough. What might one enter into the the Height property to make the template display? I found that if I added ValidatesOnExceptions=True to FeetAndInchesEditorWithValidation and then enter 5555', I'm able to see the red dot, but the tooltip doesn't show the expected "All persons more than a mile high to leave the court". Sadly it only shows "Exception has been thrown by the target of an invocation." Not nearly as satisfying. But I digress... I wish I could tell you confidently that I have VS2008 SP1, but my about box shows only "Microsoft Visual Studio 2008, Version 9.0.21022.8 RTM", although it does also show "Microsoft .NET Framework Version 3.5 SP1". I've done "Help->Check For Upgrades..." and none are offered, so I seem to be up-to-date. Yes, I did copy the samples to another directory so I wouldn't have to fight with UAC. I'm trying to play nice with Vista et al. I think I'm comfortable with chalking it up to IDE flakiness if you are. But I would like to understand more about how you intend the sample to work, i.e. what is the user expected to enter to trigger the error template? Thanks, Kevin |
|
|
I think we'll have to put the design-time error down to IDE flakiness. But it looks like something has gone a bit wrong with the sample -- the binding is looking for IDataErrorInfo and for some reason that isn't implemented on the sample data object. Not sure what happened there and apologies for the confusion. In the meantime, changing to ValidateOnExceptions=true is the right thing to do, but as you have found, WPF tends to give agonisingly bad errors in this case. The solution is to add a value converter to unpick the TargetInvocationException rubbish, and present the real honest inner exception. Here's a sample converter: public class ExceptionInfoConverter : IValueConverter And here are the changes in ErrorHandling.xaml to use it: <local:ExceptionInfoConverter x:Key="eic" /> (Pardon the rubbish names.) With these changes plus ValidatesOnExceptions=true, you should see the business-meaningful (insofar as any "Alice" reference can be considered "meaningful") exception message at last. |
|