Thursday, July 31, 2008

Handling Xaml Ui Base Classes

I was switching some of my Xaml Ui items to inherit from a common base class and started running to a problem of not being able to compile.

I kept being told that my code behind could not inherit from a different class than its partial class counterpart. Well, I know the code behind file I could see was correct, so it had to be the auto generated one that wasn't. The problem was, I had no way of editing anything about that file that I could find.

A long story short, I found a post that gave the solution. The .g.cs file isn't generated until after a certain compile point. It was using an old copy, with the previous class (Window) base, and because my code behind inherited the new one already, the .g.cs file could never be updated.

The Solution? Do not have the code behind you can directly edit inherit from any class. It is a partial class, and the .g.cs file will inherit it for you, making everything all good.

0 comments: