Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the validation error template is set to display over an entire control, you just need to adjust the bindings on your data template so that the validation error template displays over the TextBlock inside the template, rather than the entire HeaderedContentControl.</p> <p>I built a tiny app to demonstrate this. Here's the code:</p> <p><strong>The Window's XAML</strong></p> <pre><code>&lt;Window x:Class="_15001777.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:_15001777" Title="MainWindow" Width="525" Height="350"&gt; &lt;Grid&gt; &lt;ItemsControl ItemsSource="{Binding Path=Items}"&gt; &lt;ItemsControl.ItemTemplate&gt; &lt;DataTemplate DataType="{x:Type local:HeaderedItem}"&gt; &lt;HeaderedContentControl Header="{Binding Path=Header}"&gt; &lt;HeaderedContentControl.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Label VerticalAlignment="Center" HorizontalContentAlignment="Right" Content="Name" /&gt; &lt;TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=HeaderedContentControl}, Path=DataContext.Header, ValidatesOnDataErrors=True}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/HeaderedContentControl.HeaderTemplate&gt; &lt;/HeaderedContentControl&gt; &lt;/DataTemplate&gt; &lt;/ItemsControl.ItemTemplate&gt; &lt;/ItemsControl&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p><strong>The Window's Code-Behind</strong></p> <pre><code>using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; namespace _15001777 { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = this; Items = new ObservableCollection&lt;object&gt;(); Items.Add(new HeaderedItem { Header = "One" }); } public ObservableCollection&lt;object&gt; Items { get; private set; } } public class HeaderedItem : IDataErrorInfo { public object Header { get; set; } public string this[string columnName] { get { return columnName == "Header" ? "There was an error!" : null; } } public string Error { get; private set; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload