我正在尝试将组合框绑定到项目列表,但我不确定如何执行此操作。我需要在Mvvm模式下在XAML中完成它,我可以使用DevExpress。我正在尝试:
<dxg:GridControl ItemsSource="{Binding Path=TaskView}" >
<dxg:GridControl.Columns >
<dxg:GridColumn Header="Project" FieldName="Project"
DisplayMemberBinding="{Binding Path=ProjectCode, Mode=TwoWay}" AllowEditing="True">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxSettings DisplayMember="Project" ValueMember="ProductName" ItemTemplate="{Binding Path=Projects}" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="Project Description" DisplayMemberBinding="{Binding Path=ProjectName}" AllowEditing="False"/>
<dxg:GridColumn Header="Description" DisplayMemberBinding="{Binding Path=ProjectDescription}" AllowEditing="False"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView MultiSelectMode="Row" SelectedRowsSource="{Binding Path=SelectedTasks}"
ShowAutoFilterRow="False" ShowTotalSummary="True"
AllowEditing="True" />
</dxg:GridControl.View>
</dxg:GridControl>
这段代码对我来说似乎是正确的但我不能使用ItemTemplate =“{Binding Path = Projects}”,因为ComboBoxSettings不是依赖属性。这段代码工作正常,我想在gridcontrol中做类似的事情:
<dxe:ComboBoxEdit SelectedItem="{Binding Path=CurrentEmployeeName}" ItemsSource="Binding Path=EmployeeView}">
<dxe:ComboBoxEdit.StyleSettings>
<dxe:ComboBoxStyleSettings />
</dxe:ComboBoxEdit.StyleSettings>
</dxe:ComboBoxEdit>
任何人都可以给我一个线索吗?非常感谢你。
答案 0 :(得分:0)
您应该使用ComboBoxEditSettings而不是ComboBoxSettings:
<dxg:GridColumn Header="...">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding ...}" ... />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>