C# WPF - ComboBox to also be a TextBox, for example: just like in office where users can choose Font Size or enter it -
i allow users choose font size combobox, them able enter size there own, tried out property: "iseditable" (and changed true value) of combobox, when enter isn't in combobox items (for example: items are- 2,3,4;and entered- 6), shows me following message: "object reference not set instance of object".
next time post source code question.
public partial class mainwindow : window { public class someitem { public int[] numbers { get; set; } public string chosentext { get; set; } } private someitem item; public mainwindow() { initializecomponent(); this.item = new someitem{numbers=new[]{7,8,10}, chosentext="10"}; this.teststackpanel.datacontext = item; } private void button_click(object sender, system.windows.routedeventargs e) { messagebox.show(item.chosentext); } } <stackpanel verticalalignment="center" x:name="teststackpanel"> <combobox iseditable="true" width="100" itemssource="{binding numbers}" text="{binding chosentext}"/> <button content="selected value" margin="0,10,0,0" width="100" click="button_click"/> </stackpanel>
i suggest issue in combobox.text property.
Comments
Post a Comment