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

Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

Sort Posts: Previous Next
  •  03-04-2010, 3:06 PM Post no. 26006

    Huh? [:^)] Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    I have a grid bound to a list where the element type has a read-only property 'B' that is dependent on the value of another property 'A'.  When adding a new row into the grid via the InsertionRow, the available values for property 'A' are represented as items of a ComboBox which is used for the CellEditor template.  If the user selects an item from this ComboBox, I wish for the value shown in column 'B' to update accordingly.  I have tried updating the CurrentAddItem in the SelectionChanged event handler of the ComboBox but this is having no effect on the displayed value in column 'B'.

    How can I achieve this?  Even if I can only do it once the value has been committed to the DataCell from the ComboBox, this is acceptable, possible preferred.

    And I also would need to do this for editing existing items.

    I have attached an example project demonstrating this problem.

    Any assistance greatly appreciated.

    Thanks,

    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  03-05-2010, 3:01 PM Post no. 26014 in reply to 26006

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

      

    Hi Jason,

    The submitted project lacks the file CustomDataGridControl.cs in order to compile properly. Please submit a self contained project that demonstrates fully the issue in order to pursue our investigation. Thank you.

     

     


    Xceed - Software Developer and Technical Support
  •  03-08-2010, 5:30 AM Post no. 26018 in reply to 26014

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    I removed CustomDataGridControl.cs from the workspace as it's not required by the project.  Please find revised project attached.
    Associate, .NET Development
    Morgan Stanley, UK
  •  03-10-2010, 11:08 AM Post no. 26059 in reply to 26018

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    Any news on this?
    Associate, .NET Development
    Morgan Stanley, UK
  •  03-12-2010, 1:07 PM Post no. 26093 in reply to 26059

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    Support, any update on this please?
    Associate, .NET Development
    Morgan Stanley, UK
  •  03-30-2010, 7:13 AM Post no. 26328 in reply to 26093

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    Support, could you please reply on this?

    Thanks,

    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  03-30-2010, 10:59 AM Post no. 26333 in reply to 26328

    Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    Hi Neo,

    I'm not support, but I'll try to give you a suggestion. I'm new to WPF, and in last two weeks I understood that, to bind anything, to any control which holds multiple items, either in list or hierarchy, you need to create wrapper for those objects.

    If you are binding a business object, lets say, Order with properties A and B, create a new class, so called ViewModel to wrap Order into. ViewModel should also implement INotifyPropertyChanged interface, and invoke event handler once property changes. There, in wrap setter for property B, change value for A too, and invoke PropertyChanged to inform grid that A changed and that it needs to update.

     Sorry if I'm not clear and that I didn't supply an example, I'm quite busy now to write one. If you have time take a look at this article on CodeProject.
    http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx

    BR, Nikola

  •  03-30-2010, 5:45 PM Post no. 26345 in reply to 26333

    Yes [Y] Re: Updating DataCell during insertion or edition that is dependent on another DataCell changed via ComboBox

    Hi Nikola,

    Thanks for your reply.  I'm fully aware of INotifyPropertyChanged and have used it extensively - I tend to avoid where possible in favour of using BindingList and only use INotifyPropertyChanged on properties where the object reference has changed.

    However, you actually gave me a flash of inspiration for my particular case with the insertion row.  I implemented INotifyPropertyChanged on the element type and caused it to notify the cell in the insertion row for property 'B' when property 'A' was edited (using PropertyChanged in the 'set' accessor for property 'A').

    Job done!  Thanks for your assistance.  I've attached the solution project.

    PS: I noticed in my actual application, I had to set UpdateSourceTrigger="CellContentChanged" on my DataGrid, but this may be due to using TableflowView.


    Associate, .NET Development
    Morgan Stanley, UK
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.