C# WPF如何使用INotifyDataErrorInfo在文本框旁边显示错误消息
我是WPF新手,开始学习下面的教程 它使用错误模板来显示错误,如下所示C# WPF如何使用INotifyDataErrorInfo在文本框旁边显示错误消息,c#,wpf,C#,Wpf,我是WPF新手,开始学习下面的教程 它使用错误模板来显示错误,如下所示 <Validation.ErrorTemplate> <ControlTemplate> <StackPanel> <!-- Placeholder for the TextBox itself --> <AdornedElementPlaceholder x:Name="textBox"/
<Validation.ErrorTemplate>
<ControlTemplate>
<StackPanel>
<!-- Placeholder for the TextBox itself -->
<AdornedElementPlaceholder x:Name="textBox"/>
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorContent}" Foreground="Red"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ControlTemplate>
</Validation.ErrorTemplate>
我了解了如何在文本框下方显示错误消息,如教程中所示。但是,我想在文本框旁边而不是文本框下面显示错误消息
有办法吗?我试图定义一个新的网格列,并试图将StackPanel设置为该新网格的位置,但它不起作用。(Grid.Column在其中似乎无效)您需要调整
ErrorTemplate
:
请求帮助的问题必须包括所需的行为和代码,以便在问题本身中重现问题。