Reputation: 38220
I have renamed the namespace of a referenced class and WPF compiler doesn't want to take it into account: it keeps prefixing MyOldNameSpace in .g.cs file:
[System.CodeDom.Compiler.GeneratedCodeAttribute
("PresentationBuildTasks", "4.0.0.0")]
public partial class MyClass:
MyOldNameSpace.MyReferencedClass,
System.Windows.Markup.IComponentConnector {
Why ? How to fix this ? What's this obscure .g.cs file ?
Upvotes: 13
Views: 9922
Reputation: 846
Also check xmlns:local in Application.xaml. This had me going for a while...
Upvotes: 2
Reputation: 1184
Don't forget to change your Generic.xaml file too,
<ResourceDictionary
xmlns:local="clr-namespace:MyOldNameSpace">
</ResourceDictionary>
Upvotes: 2
Reputation: 3848
Maybe another case is that the build action of your xaml is not "Page" but the other options.
Upvotes: 1
Reputation: 5003
Looks like you didn't change your MyClass.xaml
file. There should be something like this on top of it
<MyClass x:Class="MyOldNameSpace.MyReferencedClass"
but should be "MyNewNameSpace.MyReferencedClass"
Upvotes: 22
Reputation: 50682
Close the .g.cs file. You can even delete it.
The g stands for generated, VS generates the wireing up between the code and the Xaml in this partial class.
Clean the solution and rebuild. That should fix it.
Upvotes: 7