Home Forums WPF controls Xceed DataGrid for WPF Decimal? cell editor?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26828 |

    Hi,

     I have to create a nullable column of type decimal?.

    So, the user can input some numeric value or leave the cell blank (null).

    By doing so, I have to explicitly set a cell editor. Otherwise the cell

    can’t be edited any more once set to null.

    Unfortunately, the CellEditor class does not expose a static numeric editor.

    How do I create the numeric editor the grid would use by default if the column

    is of type decimal? ?

     

    Thanks,

    Michael

    Imported from legacy forums. Posted by Michael (had 1205 views)

    Xceed Support
    Member
    Post count: 5658

    You simply need to assign a configured NumericEditor to the EditTemplate property of the desired column’s CellEditor property. For example:

     
    <xcdg:DataGriControl.Column>
       <xcdg:Column FieldName=”decimalColumn”>
          <xcdg:Column.CellEditor>
             <xcdg:CellEditor>
                <xcdg:CellEditor.EditTemplate>
                    <DataTemplate>
                       <xcdg:NumericEditor/>
                    </DataTemplate>
                </xcdg:CellEditor.EditTemplate>
             </xcdg:CellEditor>
          </xcdg:Column.CellEditor>
       </xcdg:Column FieldName=”decimalColumn”>
    </xcdg:DataGriControl.Column>
     

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1346 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

     

    thanks for your answer, but there is no NumericEditor in xcdg.

    You possibly mean “Xceed.Wpf.Controls.NumericTextBox” or “Xceed.Wpf.Controls.MaskedTextBox”?

    Yes, I could create a NumericTextBox, set AutoSelectBehavior, remove the Border, Padding and Margin, set the ActivationGestures, etc.

    But that still leaves me unsure if my cell editor behaves exactly the same way the default editor does.

    It would be so much simpler just to access your predefined DataTemplate as a static property of the CellEditor class. [:)]

     

    Greetings,

    Michael

    Imported from legacy forums. Posted by Michael (had 1008 views)

    Xceed Support
    Member
    Post count: 5658

    You are correct, I meant Xceed.Wpf.Controls.NumericTextBox. That said, here is the template that you can use and I will add a feature request to add static instances of these classes on the CellEditor class.

     

          <local:CellEditor>
             <local:CellEditor.EditTemplate>
                <DataTemplate DataType=”{x:Type s:Int16}”>
                   <xcdpres:NumericTextBox Value=”{markup:CellEditorBinding}”
                                           ValueDataType=”{x:Type s:Int16}”
                                           local:DataCell.IsCellFocusScope=”True”
                                           VerticalAlignment=”Stretch”
                                           Template=”{StaticResource textBoxTemplate}”
                                           Margin=”-2,0,-2,0″
                                           Background=”Transparent”
                                           Foreground=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(TextElement.Foreground)}”
                                           AutoSelectBehavior=”OnFocus”
                                           AutoMoveFocus=”True”
                                     />
                </DataTemplate>
             </local:CellEditor.EditTemplate>
             <local:CellEditor.ActivationGestures>
                <local:TextInputActivationGesture/>
             </local:CellEditor.ActivationGestures>
          </local:CellEditor>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1321 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.