Hi All,
Is it possible for a user to rename a tab? I know I can do it programmatically using Tab.text, but I'm looking for a way of the existing tab text getting selected/highlighted, and then the user being able to type a new name over the top.
Just like in MS Excel, when the user clicks on a sheet tab and chooses "Rename".
Is this acheivable, and if not, what is a good alternative for handling user tab renaming?
Any info appreciated,
Scott Pearce
Here is how I roll this smoke...Merry Christmas....
Here is the Tab MouseUp Event that gets the ball rolling...dont forget to use the text editors lost focus to hide itself when its all said and done...
It goes like this: Extract the tab, map the tab, create some geometric info, assign that info to the tab, pull up the context menu, assign the tab to the tools in the pop menu, use the geometric info to pop up the menu, then respond to the tool click and extract the prior assignments first from the tool, and then its tag (the tab)...to place your edit box
This works like a charm...Cheers
Here is the Tool Click Event...notice how we query the Tool.Tag to see if is packing a Tab, then check to see if the Tab is packing a Rectangle...we just burrow into the tool and query whats it packing to decide what to do...and in this case we display the Tab Rename edit box on target, on time....in fact parsing the Tool.Tag for its type is a slick way to handle click events...it lets you sift out the ordinary from the extraordinary in one step...
I constantly leverage the Tag property like this to extend functionality without bogging a GUI code set down with class wide variables...and other such nonsense...such as unecessary inheritence...
There is no end to how sophisticated you can get with this, as you can create custom objects, and type check against custom interfaces and pack it into a single Tag property if required..there are tons of solutions to common problems using this method...
Now thats what I call a Tag Team...
Not bad. The only suggestion I'll make is that you use the following code to find a tab's rect so you don't have to do so much work manually searching for the edges:
UIElement tabElement = this.tabAddress.UIElement.GetDescendant( typeof( TabItemUIElement ), tab );
if ( tabElement != null ){ Rectangle tabRect = tabElement.Rect; // ...}