解决控件验证没有错时xaml 绑定报错

报错为:AdornedElementPlaceholder, Name='adornedElementPlaceholder' AdornedElement.(0)[0].ErrorContent TextBlock.Text String Failed to get value. ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')'
This commit is contained in:
asine authored and GitHub committed 2025-03-06 17:25:17 +08:00
1 parent a7f0a9f3ce
commit 94f2ef85ff
1 file changed
+1 -1
@@ -50,7 +50,7 @@
</Grid.RowDefinitions>
<AdornedElementPlaceholder x:Name="adornedElementPlaceholder" />
<hc:TransitioningContentControl TransitionMode="Top2Bottom" Grid.Row="1" ClipToBounds="True">
<TextBlock Foreground="{DynamicResource DangerBrush}" Margin="2,2,0,0" Text="{Binding Path=AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName=adornedElementPlaceholder}" />
<TextBlock Foreground="{DynamicResource DangerBrush}" Margin="2,2,0,0" Text="{Binding Path=AdornedElement.(Validation.Errors)/ErrorContent, ElementName=adornedElementPlaceholder}" />
</hc:TransitioningContentControl>
</Grid>
</ControlTemplate>