Set Selected Item of WPF Combobox to User Setting -


i have combo box item source set collection of 'category'. selectedvaluepath categoryid property. have user setting 'defaultcategory' integer of should set categoryid. want combo box have selection of defaultcategory user setting.

xmlns:my="clr-namespace:myapp"  <combobox x:name="cmbcategory" displaymemberpath="category" selectedvaluepath="categoryid" selectedvalue="{binding source={x:static my:mysettings.default}, path=defaultcategory, mode=twoway}"/> 

you create additional application setting called defaultcategory_selected of type int , scope of user, , binding selectedindex property setting.

<combobox selectedindex="{binding path=defaultcategory_selected, mode=twoway}" ... /> 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

binding - How can you make the color of elements of a WPF DrawingImage dynamic? -

c# - How to add a new treeview at the selected node? -