Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Extending xamDataGrid Fields with additional properties
posted

Is there a way to extend fields in a xamDataGrid with additional dependency properties that are synchronized between the field and the editor? I know that I can use TemplateField, but I'd rather create a derived field type for commonly used scenarios.

For example, we are using a TextBox with a button to clear the content. Our MyTextBox therefore has a dp 'IsClearable'. Now I want to create a column with this TextBoxes, using a derived field MyTextField and a corresponding MyTextEditor. The user should be able to use hardcoded values, FieldBinding and CellBinding.

For convenient usage I put the dependency property 'IsClearable' on the MyTextField so the user can set it in xaml defining the data grid columns. But how do I sync this property to the corresponding dp on MyTextEditor? As far as I see there is no connection between them both. I looked into default fields and they all sync their properties hardcoded and I found no way to extend this by custom properties.

  • 45
    Verified Answer
    Offline posted

    After digging a little deeper, I found the methods InitializeEditorProperties and SynchronizeEditorProperty on type Field to override. Those methods should solve all the above mentioned problems.