Red border remains on the TextBox even after the data input is valid

前端 未结 1 1929
轮回少年
轮回少年 2021-01-12 21:51

I am writing an app using WPF, WPF Application Framework and MahApps.Metro. I have validation enabled for a data entry window like this:



        
相关标签:
1条回答
  • 2021-01-12 22:35

    I've come across this before, when it happened to me I had to perform a data change during initialize and ContentRendered. Cause I had the items actually bound.

    Another thing I saw awhile ago on Stack Overflow was an issue that happened here that also caused something similar.

    <Setter Property="Validation.ErrorTemplate">
        <Setter.Value>
            <ControlTemplate>
                <ControlTemplate.Resources>
                    <BooleanToVisibilityConverter x:Key="converter" />
            </ControlTemplate.Resources>
                <DockPanel LastChildFill="True">
                    <Border 
                        BorderThickness="1"
                        BorderBrush="Red"
                        Visibility="{Binding ElementName=placeholder, Mode=OneWay, Path=AdornedElement.IsVisible, Converter={StaticResource converter}}">
                        <AdornedElementPlaceholder x:Name="placeholder" />
                    </Border>
                 </DockPanel>
             </ControlTemplate>
        </Setter.Value>
    </Setter>
    

    That was my encounter, if that doesn't help I'll attempt to recreate the issue and fix as well. See if I can help you out a little better then describing how I fixed it. But hopefully one of those two suggestions helps you out.

    Just let me know, hope it helps.

    0 讨论(0)
提交回复
热议问题