2016-01-13 179 views
0

我試圖在WPFTOOLKIT數據網格中實現可編輯組合框。用戶必須有可能輸入新的值。綁定是用MVVM進行的。 除了這個問題之外,一切運作良好:輸入新值後,退出組合後,該值將丟失。WPF工具包可編輯組合框

這裏是我的XAML代碼:

<xcdg:Column FieldName="FlangeType" Title="Flange Type" Width="80" > 

    <xcdg:Column.CellEditor> 
      <xcdg:CellEditor> 
       <xcdg:CellEditor.EditTemplate> 
         <DataTemplate> 
          <ComboBox 
              ItemsSource="{Binding Path= DataContext.FlangeTypes, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" 
              SelectedValue="{xcdg:CellEditorBinding}" 
              Text="{Binding Path=DataContext.CurrentDrumStandard.FlangeType,UpdateSourceTrigger=LostFocus}" 
              IsEditable="True"/> 
         </DataTemplate> 
        </xcdg:CellEditor.EditTemplate> 
       </xcdg:CellEditor> 
     </xcdg:Column.CellEditor> 

</xcdg:Column> 

預先感謝任何幫助

回答

0

其實我失蹤了Text屬性的RelativeSource。

更新代碼:

       <xcdg:Column.CellEditor> 
            <xcdg:CellEditor> 
             <xcdg:CellEditor.EditTemplate> 
              <DataTemplate> 
               <ComboBox 
                ItemsSource="{Binding DataContext.FlangeTypes, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" 
                SelectedValue="{xcdg:CellEditorBinding}" 
                Text="{Binding DataContext.CurrentDrumStandard.FlangeType, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, UpdateSourceTrigger=LostFocus}" 
                IsEditable="True"/> 
              </DataTemplate> 
             </xcdg:CellEditor.EditTemplate> 
            </xcdg:CellEditor> 
           </xcdg:Column.CellEditor> 

          </xcdg:Column>