5

我在网格中有一个 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 以将其显示在我的标签中。可能吗?请你帮助我好吗?

4

1 回答 1

4

尝试

<ControlTemplate x:Key="BindingGroupШаблОш">
  <Border BorderBrush="Blue" BorderThickness="2">
    <StackPanel>
      <Label Content="{Binding Path=[0].ErrorContent}"></Label>
      <AdornedElementPlaceholder />
    </StackPanel>
  </Border>
</ControlTemplate>
于 2013-05-30T23:48:30.853 回答