I have a WPF project in Visual Studio 2013 which contains a custom control I created, containing a custom event. Whenever I drag the control into my MainWindow.xaml
file, it will display once in the designer. As soon as I compile my application (which succeeds), the designer will display something like this, showing my control is broken:
In the XAML code (again, only after the first compile), I get this tip:
However, no matter what I change my event name to (say "EggsAndBaconEvent"), it will always break the designer after the first compile.
Visual Studio will try to help me in this window:
Here is my code which is related to creating an event:
public partial class Settings : UserControl {
...
public static RoutedEvent ExpandEvent;
public Settings() {
...
ExpandEvent = EventManager.RegisterRoutedEvent("Expanded", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Settings));
}
...
public event RoutedEventHandler Exapnd {
add { AddHandler(ExpandEvent, value); }
remove { RemoveHandler(ExpandEvent, value); }
}
private void expanderChanged(object sender, RoutedEventArgs e) {
...
RoutedEventArgs args = new RoutedEventArgs(ExpandEvent);
RaiseEvent(args);
}
}
Does anyone know why Visual Studio is complaining? Is it my code or is this some strange anomaly in VS 2013?
Thank you for your time.