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 a PropertyGrid with a CLR-object as SelectedObject. This object has several properties, Name among them. I have created a Button 'Rename'. I would like when user clicked button, PropertyGrid gained focus in Name node, in order to rename object. Is it possible?
Thanks |
|
|
Unfortunately this isn't currently supported. We will look into providing a mechanism for this. To help us prioritise this, what is the importance/urgency of this feature for you? |
|
|
Our application is planned to be released in the middle of June. We would like to benefit of this feature before this date. If we were not able to do it, we will search for other solution. Thanks. |
|
|
Hello Josep, Here is one way to do this. 1. Define an attached property. You'll be using this to "tag" an editor for setting focus. I created a static class called Focuser with an attached property of type string called FocusId. 2. Define a PropertyEditor for the Name property. The EditorTemplate will be the standard text editor, but we are going to use the Style property to set the Focuser.FocusId property: <ms:PropertyEditor PropertyName="Name" DeclaringType="..." EditorTemplate="{StaticResource {x:Static ms:PropertyGrid.SimpleTextEditorKey}}"> 3. In your Focuser class, create a SetFocus function as follows: public static void TrySetFocus(DependencyObject within, string focusId) 4. Finally, in the Click handler of the Rename button, call Focuser.TrySetFocus("NameEditor"). We aren't planning to integrate focus setting support directly into the product but the code above should enable you to perform focus setting in the scenario you describe. The main downside is that it requires you to declare in the grid XAML that a particular editor needs to be focus-settable -- you won't be able to set focus to an editor that hasn't been tagged with the Focuser.FocusId property. |
|
|
Thanks for your approach. I'll try to implement it! |
|
|
Hi, You said in step 4 that I should call Focuser.TrySetFocus("NameEditor") but TrySetFocus signature has 2 parameters. Which should be the first parameter? The PropertyGrid? The PropertyEditor?
Thanks. |
|
|
That's what I get for cleaning up code in the forums editor *grin*. The first parameter should be the PropertyGrid control. |
|