INotifyDataErrorInfo多个错误

时间:2018-10-08 12:39:46

标签: inotifydataerrorinfo

我正在尝试通过将错误消息放在文本框下方来处理错误。不幸的是,这只是覆盖下面的控件。

                <TextBox x:Name="ID"
                Text="{Binding CurrentVenue.VenueID, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" >
                <Validation.ErrorTemplate>
                    <ControlTemplate >
                        <StackPanel>
                            <!-- Placeholder for the TextBox itself -->
                            <AdornedElementPlaceholder x:Name="textBox"/>
                            <ItemsControl ItemsSource="{Binding}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding ErrorContent}">
                                            <TextBlock.Style>
                                                <Style TargetType="{x:Type TextBlock}">
                                                    <Setter Property="Foreground" Value="Red"/>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding ErrorContent.Severity}"
                                                                     Value="{x:Static fluentValidation:Severity.Warning}">
                                                            <Setter Property="Foreground" Value="Orange"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </ControlTemplate>
                </Validation.ErrorTemplate>
            </TextBox>

其他人如何设法解决这个问题。我真的希望该行随着错误的更改而展开折叠。

0 个答案:

没有答案