Binding ComboBoxes to enums… in Silverlight!

后端 未结 4 656
醉梦人生
醉梦人生 2021-01-31 15:42

So, the web, and StackOverflow, have plenty of nice answers for how to bind a combobox to an enum property in WPF. But Silverlight is missing all of the features that make this

4条回答
  •  梦如初夏
    2021-01-31 15:54

    I find that a simple encapsulation of enum data is way easier to use.

    public ReadOnly property MonsterGroupRole as list(of string)
      get
        return [Enum].GetNames(GetType(GroupRoleEnum)).Tolist
      End get
    End Property
    
    private _monsterEnum as GroupRoleEnum
    Public Property MonsterGroupRoleValue as Integer
      get
        return _monsterEnum
      End get
      set(value as integer)
        _monsterEnum=value
      End set
    End Property
    

    ...

    
    

    And this will completly remove the need of a converter... :)

提交回复
热议问题