本文章仅为个人学习,如有错误之处请指正。
搭建WPF界面的时候,想用combobox构建一个下拉菜单,搜索的时候看到大多数都是大段代码,逻辑顺序不是很详细,摸索了大概,记录一下方便来者。
拖入combobox控件,控件的属性可以在xmal代码中更改,这里只是用了默认的代码,combobox的绑定在.cs代码中进行。
<Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="12,239,0,0" Name="label8" VerticalAlignment="Top" /> <ComboBox Height="23" HorizontalAlignment="Left" Margin="130,239,0,0" Name="My_combobox" VerticalAlignment="Top" Width="120