I enabled renaming by other means than F2

Jan 29, 2015 at 12:24 AM
A simple change, maybe you can tell me if there is a better method. This works fine :)


Enabling renaming through other means than the built-in “F2” press
TreeViewEx:
  • Added the StartEditingTreeItemNameGivenDataContext func
    public void StartEditingTreeItemNameGivenDataContext ( object dataContext ) {
        // Get the item to start editing 
        var treeItem = GetTreeViewItemFor( dataContext );
        bool itemFound = ( treeItem != null );
        if( itemFound ) {
            treeItem.StartEditing();
        }
    }
    TreeViewExItem:
  • Public'd StartEditing
  • Removed "IsFocused" check from StartEditing
    ( not sure why it was there, but it made my renaming not work with multiple items selected. It seems okay without it )
    public bool StartEditing()
    {
        //if (TemplateEdit != null && IsFocused && IsEditable)
        if (TemplateEdit != null && IsEditable)
Feb 5, 2015 at 8:53 PM
There is an error with this method: If you do this, the text is highlighted okay, but clicking on it doesn't work properly.
The mouse cursor stays on a pointer, instead of the vertical bar you normally get when mousing over editable text.
Then if you click the text, nothing happens. If you press a keyboard key, then the mouse works as normal.

I'm guessing it has to do with that "IsFocused" thing I removed.

I might just look into this and find some solution. :) Just letting you know it's not 100% working.