Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to programmatically get the folder name where the custom project item being added to?

$
0
0

We created a multi-file project item, this project item contains several files and a folder, text below describes the structure of these files.

CustomUiControl.xaml (file)

CustomUiControl.xaml.cs (file)

CustomUiViewModel.cs (file)

Pages (Folder)

---Page1Control.xaml (file)

---Page1Control.xaml.cs (file)

---Page1ViewModel.cs (file)

We need to use some custom replacement strings, so we create wizard that work with this template. In IWizard.RunStarted method we add some custom replacement strings intoreplacementsDictionary. The value of these replacement strings are created base on the user's input in 'Add New Item' dialog. For example if user input 'MyCustomUi', then we will create a replacement string '$CustomUiViewModel$' with value 'MyCustomUiViewModel'. But in the 'CustomUiViewModel.cs' file we need to create an instance of 'Page1ViewModel' , so we need to use the namespace of 'Page1ViewModel' in 'CustomUiViewModel.cs' file. But this namespace varies. So we create a replacement string ($SubViewModelNamespace$) for this namespace.  If we add our custom project item under a specified project folder (Let's say the folder name is 'MyCustomUIs'). The namespace of 'Page1ViewModel' should be ‘[project default namespace].MyCustomUIs.Pages'. But we can't get the folder that our custom project item being added to. So we can't create correct value for $SubViewModelNamespace$. Is there any way we can programatically get this folder name in IWizard.RunStarted method?

Thanks. 


Viewing all articles
Browse latest Browse all 4410

Trending Articles