0

我正在研究从实体模型填充的数据网格。对于特定列,我有以下内容作为在编辑期间使用组合框的尝试,并且编辑的源是 CollectionsViewSource。

      <Grid DataContext="{StaticResource vsLogins}" Grid.Column="1" 
            Margin="16,248,154,31">
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" 
                  Height="213" HorizontalAlignment="Left"
                  ItemsSource="{Binding Source={StaticResource vsLogins}}" 
                  Name="LoginsDataGrid"
                  RowDetailsVisibilityMode="VisibleWhenSelected" 
                  VerticalAlignment="Top" Width="380"
                  Background="{StaticResource lgb}" BorderThickness="2" 
                  BorderBrush="#FFFC0303">
          <DataGrid.Columns>
            <DataGridTextColumn x:Name="LoginNameColumn" Binding="{Binding 
                                  Path=LoginName}" Header="Login Name"
                                  Width="200" MinWidth="200" />
            <DataGridTextColumn x:Name="PsWrdColumn"
                                Binding="{Binding Path=PsWrd}" 
                                Header="Password" Width="130" MinWidth="130" />
            <DataGridTemplateColumn x:Name="AccessLevelIdColumn" Header="Id"
                                    Width="40" MinWidth="40">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Path=AccessLevelId}" />
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
              <DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                  <ComboBox ItemsSource="{Binding Source={StaticResource 
                             vsAccessLevels}}" DisplayMemberPath="Description" 
                         SelectedValuePath="AccessLevelId" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>
          </DataGrid.Columns>
        </DataGrid>

它抛出了一些错误。我究竟做错了什么?我还尝试在组合框周围放置一个网格并将其 dataContent 设置为 CVS - 也没有骰子。谢谢你的帮助。

4

1 回答 1

0
<DataGridComboBoxColumn x:Name="AccessIdColumn" 
                        ItemsSource="{Binding Source={StaticResource vsAccessLevels}}" 
                        DisplayMemberPath="Description" 
                        SelectedValuePath="AccessLevelId"
                        SelectedValueBinding="{Binding Path=AccessLevelId}"/>
于 2012-11-25T21:02:56.377 回答