0

我在 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?谢谢你。

4

0 回答 0