Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing namespace of the WPF Project Template

When I modify the xaml's cs's I will have to go in and manually modify the corresponding *.g.cs file. And it seems to get overwritten every time I rebuild.

So my question is, what is the proper way to change the namespace on a WPF application that has been generated by the WPF project template?

like image 779
Kwan Cheng Avatar asked Feb 10 '09 02:02

Kwan Cheng


1 Answers

Since the .g.cs files are generated from the .xaml files, besides changing the namespace in the .xaml.cs files, you also have to change the namespace in the .xaml files.

For example, the main window in one of my projects is declared like this in mainwindow.xaml:

<Window x:Class="Penov.Playground.MainWindow">

The corresponding mainwindow.xaml.cs file contains:

namespace Penov.Playground
{
    public class MainWindow
}

If I want to change the namespace from Penov.Playground, I need to change it in both places. This would result in a .g.cs files generated on the next build with the new namespace.

like image 54
Franci Penov Avatar answered Oct 15 '22 20:10

Franci Penov