This is a migrated thread and some comments may be shown as answers.

Double Click on property name

2 Answers 90 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
rodzyy
Top achievements
Rank 1
rodzyy asked on 18 Jul 2011, 12:01 PM
Hi,
I want to double click on property name to focused in value of property.
Is it possible?

2 Answers, 1 is accepted

Sort by
0
Bill
Top achievements
Rank 1
answered on 09 Oct 2012, 07:29 PM
Any updates on this? Will this be a template override? 

Also, I do not want to "tab stop" on the label of the property grid definitions. Just the editor templates. I was trying to edit the PropertyGridField style and set Focusable to false but it doesn't appear to have any effect. any ideas? (Note: I also tried the IsTabStop property)



Thanks!

Bill
0
Maya
Telerik team
answered on 10 Oct 2012, 07:42 AM
Hi Bill,

You need to find the property field corresponding to the label you double-clicked on and focus its editing element. For example:

void propertyGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var fields = this.propertyGrid.ChildrenOfType<PropertyGridField>();
            var clickedElement = e.OriginalSource as FrameworkElement;
            if (clickedElement != null)
            {
                var propertyDefinition = clickedElement.DataContext as PropertyDefinition;
                var currentField = fields.Where(f => f.DataContext.Equals(propertyDefinition)).FirstOrDefault();
                if (currentField != null)
                {
                    var editingElement = currentField.ChildrenOfType<TextBox>().FirstOrDefault();
                    editingElement.Focus();
                }
            }
        }
 
Let me know whether this approach meets your requirements.

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
rodzyy
Top achievements
Rank 1
Answers by
Bill
Top achievements
Rank 1
Maya
Telerik team
Share this question
or