WPF Binding My.Settings collection to Combobox items

前端 未结 5 1934
长情又很酷
长情又很酷 2021-02-15 16:18

I\'m VERY new to WPF, and still trying to wrap my head around binding in XAML.

I\'d like to populate a combobox with the values of a string collection in my.settings. I

5条回答
  •  臣服心动
    2021-02-15 16:52

    It is possible. In C#, I do it like this (for a simple bool):

    IsExpanded="{Binding Source={StaticResource Settings}, Mode=TwoWay, Path=Default.ASettingValue}"
    

    I define the static resource "Settings" in my App.xaml's Application.Resources thusly:

    
    
     
      
       
       
      
     
    
    

    Your path may be different; in C#, you access app settings in your application via

    DefaultNamespace.Properties.Settings.Default.ASettingValue
    

提交回复
热议问题