WPF Style Override breaks Validation Error event propagation
- by Ben McMillan
I have a custom control that overrides Window:
public class Window : System.Windows.Window
{
static Window()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new System.Windows.FrameworkPropertyMetadata(typeof(Window)));
}
...
}
It also has a style:
<Style TargetType="{x:Type Controls:Window}" BasedOn="{StaticResource {x:Type Window}}">
<Setter Property="WindowStyle"
Value="None" />
<Setter Property="Padding"
Value="5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:Window}">
...
Unfortunately, this breaks the propagation of the Validation.ErrorEvent for my window's contents. That is, my window can receive the event just fine, but I don't know what to do with it to mimic how a standard Window (or whoever) deals with it.
If the validating controls are placed in a standard window, they work. They also work if I just take out the OverrideMetadata call (leaving them inside my custom window).
Why is this happening, and how can I get the stock functionality for handling these validation error events working again?
Thanks!