combobox绑定值为什么没有绑定上,少了什么属性或者哪里写错了吗? 求指教%>_<%
xaml文件:
- <c1:DataGridComboBoxColumn Width="80" HeaderStyle="{StaticResource ColumnHeaderStl}" TextWrapping="Wrap" IsReadOnly="False"
- Header="依頼元"
- SelectedValuePath="Id"
- DisplayMemberPath="Name"
- [color=Red] ItemsSource="{Binding IraiMtList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"[/color]
- DropDownHeight="20"
- Binding="{Binding IraiMt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- />
- <!--xmlns:localsss="clr-namespace:Spice_New.View"--><!--<Page.Resources>
- <localsss:ComboValues x:Key="cmbValues"/>
- </Page.Resources>-->
- <!--ItemsSource="{StaticResource cmbValues}" 不这么写呢 这么写是不是得创建多个ComboValues文件啊 这样不太好啊。。。 -->
复制代码
viewmodel:
- //想这么绑定可以吗? (づ ̄3 ̄)づ╭?~
- [color=Red]this.IraiMtList = new ObservableCollection<ComboBoxModel>() {[/color]
- new ComboBoxModel() {Id = 1, Name="ハード"},
- new ComboBoxModel() {Id = 2, Name="ソフト"},
- new ComboBoxModel() {Id = 3, Name="ヒューマン"},
- };
复制代码
model:
- namespace Spice_New.Model
- {
- /// <summary>
- /// ComboBoxModel
- /// </summary>
- public class ComboBoxModel
- {
- /// <summary>
- /// Id
- /// </summary>
- public int Id
- {
- get;
- set;
- }
- /// <summary>
- /// Name
- /// </summary>
- public string Name
- {
- get;
- set;
- }
- }
- }
复制代码 |
|