gpt4 book ai didi

wpf - 从 ErrorTemplate 访问 Validation.Errors

转载 作者:行者123 更新时间:2023-12-04 20:11:29 25 4
gpt4 key购买 nike

我在网格中有一个 BindingGroup:

<Grid x:Name="участнКонтейн" DataContext="{Binding Source={StaticResource участнПк}}"
Grid.RowSpan="1" Grid.Row="1" HorizontalAlignment="Center">
<Grid.BindingGroup>
<BindingGroup NotifyOnValidationError="True">
<BindingGroup.ValidationRules>
<цл:валидУчастн ValidationStep="ConvertedProposedValue" />
</BindingGroup.ValidationRules>
</BindingGroup>
</Grid.BindingGroup>
<Grid.Style>
<Style>
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource BindingGroupШаблОш}" />
</Style>
</Grid.Style>
...

我的网格有一个 ErrorTemplate:
<ControlTemplate x:Key="BindingGroupШаблОш">
<Border BorderBrush="Blue" BorderThickness="2">
<StackPanel>
<Label Content="My BindingGroup Error should be here!"></Label>
<AdornedElementPlaceholder />
</StackPanel>
</Border>
</ControlTemplate>

我想从我的 ControlTemplate 访问 Validation.Errors[0].ErrorContent 以在我的标签中显示它。是否可以?请你帮助我好吗?

最佳答案

尝试

<ControlTemplate x:Key="BindingGroupШаблОш">
<Border BorderBrush="Blue" BorderThickness="2">
<StackPanel>
<Label Content="{Binding Path=[0].ErrorContent}"></Label>
<AdornedElementPlaceholder />
</StackPanel>
</Border>
</ControlTemplate>

关于wpf - 从 ErrorTemplate 访问 Validation.Errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16847308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com