Thursday, March 21, 2013

XamlParse Exception for that darn FrameworkElement MeasureOverride

I just wrangled with that fun and oh so detailed error of the XamlParseException that tells you something is wrong with your FrameworkElement MeasureOverride.

After hitting my head on my desk, cursing in my mind (cubicles aren't very private) and wanting to chuck my computer through the window, I figured it out.

This probably won't work for everyone, but it could be a good starting point. In my codebehind I had a SizeChanged declared.

public myControl()
    this.SizeChanged += new SizeChangedEventHandler(myControl_SizeChanger);

Once I commented out (and then got rid of) the size changed event, the error went away.

to get the autosizing I wanted on this control, in the main "header" (that's what I call the code at the top that declares all of the xmlns values), I set a DESIGN height and width instead of simply stating Height and Width :


<UserControl x:Class="application.myClass"
                     mc:Ignorable="d"  d:DesignHeight="100" d:DesignWidth="100">

.... rest of code here

No comments:

Post a Comment