Tuesday, May 01, 2012 9:12 PM
I came here tonight because i'm a bit desperate....
I try to create a Visual Studio extension, using some custom project/item templates, associated wizards and one VSPackage. The wizards and VSPackage are in the same assembly.
Recently, i try to create an UI to customize items created using my item template...especially the item's name.
However, if everything works fine, only one thing makes me crazy : I can't change the item's name if the wizard had started O_o.
I already tried something like replacementDictionary["$rootname$"] = "OneGreatName.cs" or removing this key before adding it in the dictionary again but the result remains unchanged : The created item in Visual Studio has the name entered in Add New Item dialog (or the name given in the mySelectedProjectItem.ProjectItems.AddFromTemplate if it was my package which initiate item creation).
Can we change existing key in replacementDictionary? If not, did it exist any way to achieve that?
Thanks for reading ;)
PS : I'm not very good in english speaking ^^. Pleasy, forgive me if i made a lot of mistakes.
Wednesday, May 02, 2012 10:08 PM
I haven't very good news for me :s
After debugging my wizard execution and analyzing the content of Wizard.Execute method in the assembly Microsoft.VisualStudio.TemplateWizard.dll, it seams that $rootname$ is just given for information during execution of the IWizard list referenced in one vstemplate file. The value of $rootname$ is extracted from an Object array passed to the Execute method by some native code and during the parameters replacement, the code doesn't take care of any changes applied to $rootname$ value; it only use the value from this Object array :s.
If someone know how to change this Object array context, i really appreciate it...perhaps with help of any Visual Studio service interface which would interact between end of "Add New Item" dialog but just before the start of wizard procedure.
- Edited by Nisnor31 Wednesday, May 02, 2012 10:10 PM
Friday, May 04, 2012 3:37 AMModerator
Thank you for your question.
I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
Thank you for your understanding and support.
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Friday, May 04, 2012 6:11 PMModerator
The wizard starts after you select the template in the New Item/Project dialog and hit the next button, so it has no control over what appears in the Name field.
However, you may have noticed that the Name field does change as you select various templates. This is controlled via an optional element in the .vstemplate file. Specifically, the DefaultName Element.
If your .vstemplate includes this element, this is the name that will be the default in the New Item/Project dialog.
Currently, there is no programatic access to the dialog itself, so you cannot effect any changes to that Name field outside of usign the optional DefaultName element in your templates .vstemplate file.
Saturday, May 05, 2012 1:43 PM
Thanks for your answers.
It confirms what I suspected with my investigation. Due to this point, I created an additional Form which allows the user to enter item's name when he uses my command instead of the "Add>New Item..." context menu. This Form appears before I call "<ProjectItem>.ProjectItems.AddFromTemplate" method.