how to prevent myControl.g.cs from overwriting with wrong base class
- by Jonny Cundall
I've got two custom cursors for my app, MyCursor and MyOtherCursor, both of which were designed in xaml, and I added some behaviour in the xaml.cs for each of them. This behaviour was the same for both so I had them inherit from a base class to reduce code duplication.
public partial class myCursor: CursorBase
{
public InterchangeCursor()
{
InitializeComponent();
}
}
public class CursorBase : UserControl
{
public virtual void MoveTo(Point pt)
{
this.SetValue(Canvas.LeftProperty, pt.X);
this.SetValue(Canvas.TopProperty, pt.Y);
}
}
my problem is that if I change something in the xaml for MyCursor, the MyCursor.g.cs file is regenerated, and instead of inheriting from CursorBase, the partial class in the g.cs inherits from System.Windows.Controls.UserControl. Since the other side of the partial class in the xaml.cs file still inherits CursorBase, a build error occurs. I'm finding it annoying fixing the g.cs file each time. Does anyone know how to prevent this happening?