Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to rename MainWindow

In Visual Studio 2010, if I create a new project that is a WPF Application, the MainWindow subclass of Window is provided as a default first window. The steps I've been taking to rename MainWindow are:

  • Use Solution Explorer to rename MainWindow.xaml.
  • Rename the class in MainWindow.xaml.cs.
  • Select the "Rename 'MainWindow' to ..." option from the "Options to update references to the renamed object" popup menu which appears next to the renamed class.
  • Update StartupUri in App.xaml accordingly.

Is there a better way? :-)

like image 306
dharmatech Avatar asked Apr 04 '12 01:04

dharmatech


4 Answers

  1. Get ReSharper
  2. Use Rename
  3. ????
  4. Profit
like image 115
Raj Ranjhan Avatar answered Oct 06 '22 01:10

Raj Ranjhan


I cannot think of a better way. An alternative which may result in less steps could be to create a new window and then set the StartupUri to the name of your new window.

It is then up to you whether you want to keep MainWindow or delete it (which would make sense if you are not using it at all).

like image 27
onefootswill Avatar answered Oct 05 '22 23:10

onefootswill


Visual C# 2010 Express Has a built in option to solve this.You can see the menu bar has an option "Refactor" where you can see two sub-menu Rename and Refactor.To change any name you just have to take the cursor on the name(Calculater in image) and click right button.Then go to Refactor and click Rename.You will see a dialog box comes and then you put the new name you want to give to your attribute.

enter image description here

like image 26
Md Ashaduzzaman Avatar answered Oct 06 '22 00:10

Md Ashaduzzaman


You can use Resharper for .NET

enter image description here

enter image description here

It will take care of all referencing to the MainWindow (including App.xaml)

like image 22
wbadry Avatar answered Oct 06 '22 00:10

wbadry