此视图不允许使用EditItem

时间:2015-03-19 01:09:38

标签: wpf grid datagridtextcolumn

  <DataGrid x:Name="dataGrid"
            ItemsSource="{Binding}"
            AutoGenerateColumns="False"
            IsReadOnly='False'
            Margin="1,3,6,3"
            Height='135'
            Width='180'
            >
    <DataGrid.Columns>
      <DataGridTextColumn Header=" Numbers" Binding="{Binding name}" />
      <DataGridTextColumn Header=" Numbers" x:Name='Lnumber' Binding="{Binding Lilies_number}"   />
    </DataGrid.Columns>
  </DataGrid>

当我运行项目时,总是,我有[此视图不允许使用EditItem]

dataGrid.ItemsSource = Data.ctxSvc.GetAllTheLiLies();

1 个答案:

答案 0 :(得分:0)

当我添加时,我找到了答案,

            EnableRowVirtualization="True"

工作正常,

  <DataGrid x:Name="dataGrid"
            EnableRowVirtualization="True"
            ItemsSource="{Binding}"
            AutoGenerateColumns="False"
            IsReadOnly='False'
            Margin="1,3,6,3"
            Height='135'
            Width='180'
            >
    <DataGrid.Columns>
      <DataGridTextColumn IsReadOnly='True' x:Name ='Lname'  Header=" Name " Binding="{Binding name}" />
      <DataGridTextColumn Header=" Numbers" x:Name='Lnumber' Binding="{Binding Lilies_number}"   />
    </DataGrid.Columns>
  </DataGrid>