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
|
When I try to use built-in DateTimePicker , I have an NullReferenceException. Perhaps this is a localization problem? I would like to know how to translate DateTimePicker in French?I have also a strange problem. In my (complex) application, when I test WPF PropertyGrid I cannot change value of string . I can only uses my backspace key.I have done a small sample to demonstrate the problem… but it works fine with the sample. Have you any idea concerning this keypress problem?Thank you in advance for your help, Cedric.
|
|
|
Hello Cedric, We haven't been able to reproduce the NullReferenceException or the string problem. Both of these features are working fine in our tests even when we change the locale. Can you send us the stack trace of the NullReferenceException? As for the string issue, could the grid be enclosed in any containers which might be intercepting keystrokes (e.g. handling a PreviewKeyXxx event)? There is a localisation bug in the calendar control, and it doesn't currently support translation except through using a custom template. Thanks for reporting these problems: we'll look into them and should have a fix for you soon. |
|
|
Hello Cedric, Regarding localisation/translation of the calendar, this occurs because WPF does not automatically use the thread locale for value converters. (I am assuming that your thread locale is set to French.) To get WPF to translate the date/time text correctly, you need to set the xml:lang attribute on your Window object (or other suitable element): <Window xml:lang="fr-FR" ...> (If you need to do this programmatically, you can do it by setting the UIElement.Language property. Sebastien Lambla has more info at http://serialseb.blogspot.com/2007/04/wpf-tips-1-have-all-your-dates-times.html if you're interested.) This deals with the display of dates, which just leaves the "Today" button. We've added a feature to support this, which will be available in nightly builds numbered 20080529 and above, available from about 1800 GMT from http://www.mindscape.co.nz/Products/WpfPropertyGrid/nightlybuilds.aspx (trial edition) or the Mindscape store (retail edition). Once you've got this nightly, you can set the Today text by adding an entry to your window Resources section: <Window xmlns:sys="clr-namespace:System;assembly=mscorlib" ...> The calendar will then pick up your content rather than the default text. |
|
|
Hi Hivan, Thank you for your fast answer. The xml:lang="fr-FR" works fine And for have you got a tip about the colorPicker and associate color name? Concerning the DateTimePicker, the problem is because my Date Property is not set yet and contains "null". So It seems ColorPicker allows null value, but not DateTimePicker. ... but perhaps this is a normal behavior ? Concerning the fact that we cannot changes any property in my sample, it seems to be because the ""XAML window" that owned the PropertyGrid is owned by a "Winform application. I have attached with this message a demo project to reproduce the problem. 1/Launch the project 2/ Press "TestWPFProperties" Menu 3/ Press "1_Load & Show in Grid" 4/ try to change a text property è this is impossible This issue concerning mixing winform and wpf in the same project is not critical for us, since we are moving our application to be "full wpf"... but It be interresting to know. Thank you for your help, Regards, Cedric. |
|
|
Thanks for the repro sample. The string editing issue occurs because WPF's internal dispatcher loop is not being initialised. There are two ways to fix this: 1. Instead of launching a WPF Window directly, host your WPF content on a Windows Form using the ElementHost control. See the WindowsFormsHosting sample included with the WPF Property Grid. 2. Instead of calling wnd.Show() directly, show the window as follows: System.Windows.Application app = new System.Windows.Application(); The first is the "official" way to use WPF content in WinForms, but can be a bit annoying to use (note the caveats and instructions in the sample). The second is a quicker fix for your sample, but I am not sure how it would play out in a more complex app with multiple windows opening and closing (since Run() blocks). We have now reproduced the bug with the date control -- thanks for your help on this. We don't have a fix for this yet, but I would point out that an uninitialised DateTime field defaults to 1 January 0001, which is probably not a good thing for users to see, so you might want to consider initialising your DateTime fields to a more user-friendly default anyway. (This is not to excuse the crashing behaviour, just to suggest that the situation in which it occurs is one that you might prefer to avoid for other reasons anyway.) We will look into providing a translation hook for the colour picker. Unfortunately WPF doesn't contain localised names for the standard colours so we can't do this automatically (we currently pick up the names from the System.Windows.Media.Colors class). How important/urgent is this for your application? |
|
|
Thank you to point me the « official » way for mixing WPF and WinForm. It is working fine :) I have also tested the 20080529 nightly build and work like a charm for me. Concerning the DateTimePicker, I would appreciate, for my application, instead of having an arbitrary default date/color, a message like "Not set". Is it possible? (Same for the other built-in editor) Concerning the ColorPicker, we would like to use it in few weeks, but we can build our own one. I am sorry I my question look stupid but I did not find a way to be informed that any of the properties were changed. Is there a way to do that? I would like to compliment you for your product and for the reactivity of your support. It is great!
|
|
|
Regarding the date-time picker: because DateTime is a value type, we have no way of knowing whether a DateTime value is uninitialised or whether you really want it to be 1 Jan 0001. So the calendar control can't do what you want. What you could do, however, is change your class design so that your property is of type Nullable<DateTime> and create a custom editor that knows about nullable DateTimes and provides a special display for the null value. For information about creating custom editors, see the Editors sample or the blog posts on Type and Property editors (http://www.mindscape.co.nz/blog/index.php/2008/01/24/custom-property-editors-in-the-wpf-property-grid/ and http://www.mindscape.co.nz/blog/?p=90). You can use the DropDown and Calendar controls to help you construct your custom editor. (The DropDown control may also be handy if you decide to build your own colour picker.) The property grid does not send property change notifications. Instead, implement INotifyPropertyChanged on your business object and subscribe to the PropertyChanged event. This is recommended anyway for any object that will be used in a WPF user interface, because WPF data binding relies on INotifyPropertyChanged to update the UI when the object changes. If you are not familiar with INotifyPropertyChanged, the test data in the samples show an example of how to implement it. |
|
|
Thank you Ivan. I was thinking DateTime was a class not a struct! If we bought the source code, will it be easy to update the built-in editor source code? How often is updated the source code?Concerning the IPropertyChanged interface, it is problematic since in the winform propertygrid there is a PropertyValueChanged event that is raised when a property is changed. When using IPropertyNotifiedChanged we have a message for each keystroke on the property. So if the user change 10 letters (eg "test" to "test1234567890") on the property then we will receive 10 messages instead of 1 ( and we are saving data on each changed this is not very interesting for us). But we have managed that, now it is ok.
My question will be certainly looks stupid but I do not know how to do that ?( see attached file). Thank you.
|
|
|
If you bought the source code, you would certainly be able to update the built-in editor source code. This should be reasonably easy to do -- the editors are fairly simple and when they use custom controls these are generally pretty small and simple too. We release nightly builds of the source code just as we release nightly builds of the grid. I guess that on average we make minor updates to the grid once or twice a week, though these are generally pretty small -- minor enhancements and bug fixes. Of course you don't need to take the updates if they are not addressing a feature or bug that affects you. Regarding your display question, in your TypeEditor or PropertyEditor declaration, set AllowExpand="True". |
|
|
Thank you for your help. We have ordered Entreprise Edition today. |
|