XCeed WPF DataGrid CollectionView编辑行

时间:2017-09-28 07:22:47

标签: wpf datagrid xceed-datagrid

我在XCeed WPF DataGrid中编辑行时遇到问题。当用户聚焦单元格时,会出现编辑符号,但不能插入任何内容。在XAML中就是这个东西

<xcdg:DataGridCollectionViewSource x:Key="DataGridSource"  Source="{Binding ActorsCollection, UpdateSourceTrigger=PropertyChanged}"/>

<xcdg:DataGridControl Name="GridControl" Grid.Row="1" ItemsSource="{Binding ActorView}" SelectedItem="{Binding CurrentActor}"
                      AutoCreateColumns="True" ReadOnly="{Binding IsDataGridReadOnly, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,5">
  <xcdg:DataGridControl.View>
    <xcdg:TableflowView UseDefaultHeadersFooters="False">
      <xcdg:TableView.Theme>
        <xcdg:RoyaleNormalColorTheme/>
      </xcdg:TableView.Theme>

      <xcdg:TableflowView.FixedHeaders>
        <DataTemplate>
          <xcdg:ColumnManagerRow/>
        </DataTemplate>
      </xcdg:TableflowView.FixedHeaders>
    </xcdg:TableflowView>
  </xcdg:DataGridControl.View>

  <xcdg:DataGridControl.ContextMenu>
    <ContextMenu>
      <MenuItem Header="{StaticResource ViewGenreContextMnuDelete}" Command="{Binding DeleteActorCommand}">
        <MenuItem.Icon>
          <Image Source="/Resources/delete.png" Height="16" Width="16"/>
        </MenuItem.Icon>
      </MenuItem>
    </ContextMenu>
  </xcdg:DataGridControl.ContextMenu>

  <xcdg:DataGridControl.DefaultCellEditors>
    <xcdg:CellEditor x:Key="{x:Type s:String}">
      <xcdg:CellEditor.EditTemplate>
        <DataTemplate>
          <TextBox Text="{xcdg:CellEditorBinding}"/>
        </DataTemplate>
      </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    <xcdg:CellEditor x:Key="{x:Type s:Int32}">
      <xcdg:CellEditor.EditTemplate>
        <DataTemplate>
          <xctk:DecimalUpDown Value="{xcdg:CellEditorBinding}"/>
        </DataTemplate>
      </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    <xcdg:CellEditor x:Key="{x:Type s:DateTime}">
      <xcdg:CellEditor.EditTemplate>
        <DataTemplate>
          <xctk:DateTimePicker Value="{xcdg:CellEditorBinding}"/>
        </DataTemplate>
      </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>
  </xcdg:DataGridControl.DefaultCellEditors>

  <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName="Firstname" Title="{StaticResource ViewDubbingActorGridColumnFirstName}" MinWidth="180"/>
    <xcdg:Column FieldName="Lastname" Title="{StaticResource ViewDubbingActorGridColumnLastName}" MinWidth="180"/>
    <xcdg:Column FieldName="AdditionalName" Title="{StaticResource ViewActorGridAdditionalName}" MinWidth="200"/>
    <xcdg:Column FieldName="AdditionalInformation" Title="{StaticResource ViewActorGridAdditionalInformation}" MinWidth="250"/>
    <xcdg:Column FieldName="Born" Title="{StaticResource ViewActorGridBorn}" MinWidth="180"/>
    <xcdg:Column FieldName="Dead" Title="{StaticResource ViewActorGridDead}" MinWidth="180"/>
    <xcdg:Column FieldName="Bornlocation" Title="{StaticResource ViewActorGridBornlocation}" MinWidth="180"/>
    <xcdg:Column FieldName="Deadlocation" Title="{StaticResource ViewActorGridDeadlocation}" MinWidth="180"/>
  </xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>

Grid的DataSource是一个CollectionView,用于过滤,分组等。当我将属性 AutoCreateColumns 设置为 true 时,工作和用户可以编辑该行。有人有什么建议吗?

另一个问题是,当用户打开DateTime选择器时,有一个非常奇怪的年份(0001),是否可以设置默认的日期时间,例如DateTime.Now?谢谢。

0 个答案:

没有答案