remove red rectangle around combobox

与世无争的帅哥 提交于 2019-11-29 23:54:47
Fredrik Hedblad

Use this to modify the Validation.ErrorTemplate

<ControlTemplate x:Key="ComboBoxValidationErrorTemplate">
    <DockPanel>
        <Border BorderBrush="Blue" BorderThickness="4">
            <AdornedElementPlaceholder />
        </Border>
    </DockPanel>
</ControlTemplate>

And then use it in your ComboBox like

<ComboBox Validation.ErrorTemplate="{StaticResource ComboBoxValidationErrorTemplate}"
          ...>

To have no indication of a Validation Error, remove the DockPanel, set Visibility to Collapsed or any other way you like.

Almost forgot, probably the easiest way to remove the "Red Border"

<ComboBox Validation.ErrorTemplate="{x:Null}"
          ...>

Add your Combobox, Validation.ErrorTemplate="{x:Null}" ; this code is ignore errors.

The setter in your trigger is setting the Visibility property of an element named "NotValid". That is not defined in the XAML you posted. If there is no element named "NotValid", that is your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!