Hi, I'm about to start creating a new application that loads a project class containing various configuration parameters and descriptions,
Being this class something that has to be updated by the application and that will be modified in time adding new properties I wanted to use the XamPropertyGrid control to edit its contents.
The Property grid is ruled by attributes and this means that properties descriptions must be written in code and cannot be resources.
So I was wondering, is it possible to replace at runtime the property descriptions if I need to manage different cultures?
Elsewhere I need to use a different editor custom built.
thank you in advance
Sabrina
Hello Sabrina,
Thank you for your post. I have been looking into it and as far as I know the Description attribute should be set to a const value, but I can suggest you ask how you can localize it in the MSDN forums, where you can get an answer from a MS expert. As for the custom editor, I can suggest you see the sample in the Samples Browser under xamPropertyGrid / Editing & Selection / Changing the Default Editors section, where it is shown how to chnage the default editor. Please let me know if you have further questions on this matter. Looking forward for your reply.
Thank you, I found the property grid exactly thanks to the sample you suggested, so definitely localization through attributes is overly complicated I've found a couple of samples and it is not exactly straightforward. But...
Looking at the propertygrid sample I see that the description (the one that has the need to be localized) appears in the "help" section of the property grid, so if that object is accessible, it can probably be bound to a property in the form model where I can set the translated description when the user selects a property.
Do you think this can be done?
Thank You in advance
I have used attributes to localize enum descriptions. Maybe you can use the same approach to keep your code clean and simple. I haven't tried it myself for the xamPropertyGrid, but it may be worth a look.
http://brianlagunas.com/localize-enum-descriptions-in-wpf/
Here you go. The solution you have been waiting for :0)
http://brianlagunas.com/localize-property-names-descriptions-and-categories-for-the-xampropertygrid/
Let me know if this was helpful.
I actually tested it and got it working perfectly. I have the Description, DisplayName, and Category all localized with a simple attribute. I am writing a blog about it right now. I will post the link when I am done. Should be today.
I've read the article and it looks promising :o) I'll experiment on this, thank you for the tip.