2015-08-11 3 views
0

Я использую WPF, MVVM, DevExpress. Я пытаюсь создать управление сеткой с 4 столбцами. Cloumns 0 и 1 - ComboBoxEdit.Handle ComboBoxEdit в GridControl

NB: Я заселить ComboBoxEdit в Col 1, используя результат comboBoxEdit в седловине 0.

Моя проблема заключается в том, что элементы в comboboxEdit Col 1 во всех строках всегда основаны на comboxBoxEdit Col 0, которые существуют в последняя строка. Другими словами, у меня всегда одни и те же элементы в comboBoxEdit 1 во всех строках.

Как я могу достичь своей цели.

Ниже мой код:

MyView.xaml

<dxg:GridControl x:Name = "FilterGridControl" AutoGenerateColumns = "AddNew" ItemsSource = "{Binding Path=FilterList, Mode=TwoWay}" EnableSmartColumnsGeneration = "True" SelectionMode = "Row" SelectedItems = "{Binding SelectedFilter, Mode=TwoWay}"> 
<dxg:GridControl.Columns> 
    <dxg:GridColumn Header = "Table" FieldName = "Table" HorizontalHeaderContentAlignment = "Center"> 
     <dxg:GridColumn.CellTemplate> 
      <DataTemplate> 
       <dxe:ComboBoxEdit x:Name = "PART_Editor" IsTextEditable = "False" ItemsSource = "{Binding DataContext.FilterTables, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" SelectedItem = "{Binding DataContext.SelectedFilterTables, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"></dxe:ComboBoxEdit> 
      </DataTemplate> 
     </dxg:GridColumn.CellTemplate> 
    </dxg:GridColumn> 
    <dxg:GridColumn Header = "Table Field" FieldName = "TableField" HorizontalHeaderContentAlignment = "Center" SortOrder = "Ascending" SortIndex = "0"> 
     <dxg:GridColumn.CellTemplate> 
      <DataTemplate> 
       <dxe:ComboBoxEdit x:Name = "PART_Editor" IsTextEditable = "False" ItemsSource = "{Binding DataContext.FilterColumns, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ValueMember = "Name" DisplayMember = "Name" EditValue = "{Binding DataContext.SelectedFilterColumns, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"></dxe:ComboBoxEdit> 
      </DataTemplate> 
     </dxg:GridColumn.CellTemplate> 
    </dxg:GridColumn> 
    <dxg:GridColumn Header = "Name" FieldName = "Name" HorizontalHeaderContentAlignment = "Center"> 
     <dxg:GridColumn.EditSettings> 
      <dxe:ComboBoxEditSettings IsTextEditable = "False" ItemsSource = "{ Binding EnumNameFilter}"></dxe:ComboBoxEditSettings> 
     </dxg:GridColumn.EditSettings> 
    </dxg:GridColumn> 
    <dxg:GridColumn FieldName = "Value" HorizontalHeaderContentAlignment = "Center"/> 
</dxg:GridControl.Columns> 
<dxg:GridControl.View> 
    <dxg:TableView Name = "view" AllowPerPixelScrolling = "False" ShowTotalSummary = "True"> 
     <i:Interaction.Behaviors> 
      <utilities:FocusNullRowBehavior/> 
     </i:Interaction.Behaviors> 
    </dxg:TableView> 
</dxg:GridControl.View> 

MyViewModel.cs:

public string SelectedFilterTables { 
    get { 
     return _selectedFilterTables; 
    } 
    set { 
     this._selectedFilterTables = value; 
     InitialiseFilterColumns(); 
    } 

)

public void InitialiseFilterColumns() { 
    if (_selectedFilterTables != null) { 
     _selectedFilter = new FilterDefinition(); 
     _selectedTable = null; 
     _selectedFilter.TableField = null; 
     _selectedFilter.Value = null; 
     _filterColumns = null; 
     _selectedTable = _tables.First(x = > x.Name == _selectedFilterTables); 
     _filterColumns = new ObservableCollection <Column> (_selectedTable.Columns.ToList()); 
     OnPropertyChanged("FilterColumns"); 
    } 
} 

Заранее спасибо.

+0

Что вы достигли до сих пор? – netaholic

ответ

0

Непонятно, в чем проблема. Я предлагаю вам создать свойство на вашей виртуальной машине как:

public IEnumerable<FilterColumns> FilterColumnsCollection 
{ 
    get { return FilterList.LastOrDefault().FilterColumnsCollection} set {} 
} 
+0

проблема в том, что элементы во всем comboBoxEdit 1 (во всех строках) являются результатом элемента select в comboBoxEdit 0, который находится в последней строке. Обычно каждые две выпадающие списки в одной строке независимы от другого comboBox в остальных строках. Но я пока не могу этого достичь – xtensa1408

Смежные вопросы