remove red rectangle around combobox

前端 未结 3 590
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 11:59

i need to remove red rectangle around combobox. I have setup combobox in xaml like (below) this and i`m trying to override of the Validation.ErrorTemplate.

          


        
相关标签:
3条回答
  • 2020-12-24 12:37

    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}"
              ...>
    
    0 讨论(0)
  • 2020-12-24 12:46

    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.

    0 讨论(0)
  • 2020-12-24 12:59

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

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