Mikhail
Mikhail

Reputation: 170

Validation errors not displayed after applying custom window style & template (c#, WPF)

In my application resources I have the following style defined, well, I'm giving you the simplistic version (style is meant to be applied to all windows across the application):

<Style TargetType="{x:Type Window}" BasedOn="{StaticResource {x:Type Window}}">
<Setter Property="Template">
<!--Omitting irrelevant property setters-->
<Setter.Value>
 <ControlTemplate TargetType="{x:Type Window}">
  <StackPanel>
   <ContentPresenter/>
  </StackPanel>
 </ControlTemplate>
</Setter.Value>
</Setter>
</Style>

I've noticed that when this style gets applied to all windows, validation errors (IDataErrorInfo) — by means of the default red-border-box-around-control error template — aren't displayed in those windows.

What gives?

Upvotes: 3

Views: 97

Answers (1)

Mikhail
Mikhail

Reputation: 170

Wrapping the window template (StackPanel in this example) into an AdornerDecorator solved this (as the decorator is used to display validation errors).

Thanks to Will, I didn't even know what to look for.

Upvotes: 3

Related Questions