Welcome to the Xceed Community | Help
Community Search  
More Search Options

Providing a complex cell editor

Sort Posts: Previous Next
  •  10-09-2008, 9:00 AM Post no. 28172

    Providing a complex cell editor

    The following example demonstrates how to change the edit template of the cell editor for the Freight column to a custom calculator control. The C# code for the Calculate method called in the buttons' Click event simply calculates the new equation and is not provided. To shorten the code, some of the Button and KeyActivationGesture declarations have been removed.

    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                        Source="{Binding Source={x:Static Application.Current}, Path=Orders}"/>
      </Grid.Resources>

       <xcdg:DataGridControl x:Name="OrdersGrid"
                             ItemsSource="{Binding Source={StaticResource cvs_orders}}">
          <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="Freight">
               <xcdg:Column.CellEditor>
                  <xcdg:CellEditor>
                     <xcdg:CellEditor.EditTemplate>
                        <DataTemplate>
                            <DockPanel>
                               <TextBlock x:Name="actual_value"
                                         Text="{xcdg:CellEditorBinding}"
                                          DockPanel.Dock="Top"/>
                               <UniformGrid Columns="4" x:Name="parentPanel"
                                            Tag="{Binding ElementName=actual_value,
                                                          Path=Text,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}"
                                            Button.Click="Calculate"
                                            DockPanel.Dock="Top">
                                  <Button x:Name="seven" Content="7"/>
                                  <!-- ... -->
                                  <Button x:Name="addition" Content="+"/>
                               </UniformGrid>
                               <TextBlock x:Name="current_equation" DockPanel.Dock="Bottom"/>
                             </DockPanel>
                         </DataTemplate>
                     </xcdg:CellEditor.EditTemplate>
                     <xcdg:CellEditor.ActivationGestures>
                        <xcdg:KeyActivationGesture Key="NumPad0"/>
                        <!-- ... -->
                        <xcdg:KeyActivationGesture Key="NumPad9"/>
                     </xcdg:CellEditor.ActivationGestures>
                  </xcdg:CellEditor>
               </xcdg:Column.CellEditor>
            </xcdg:Column>
          </xcdg:DataGridControl.Columns>
       </xcdg:DataGridControl>
    </Grid>



View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.