Default value for comboBox

前端 未结 2 1388
生来不讨喜
生来不讨喜 2021-01-07 14:18

Hi I try set default value for comboBox.

XAML:

        

        
相关标签:
2条回答
  • 2021-01-07 14:27

    You do not need to create your own empty string, string has a static field for that, so you could set it in the style like this:

    Value="{x:Static System:String.Empty}"
    

    And why don't you just use a normal setter in your style right away?

    <Style x:Key="statusComboStyle" TargetType="{x:Type ComboBox}">
        <Setter Property="SelectedIndex" Value="0"/>
    </Style>
    

    (You should make sure that there is at least one item in the ComboBox)

    0 讨论(0)
  • 2021-01-07 14:49
    Binding="{Binding Path=Name.Length, FallbackValue=0, TargetNullValue=0}" Value="0">
    
    0 讨论(0)
提交回复
热议问题