Custom Command Provider executing actions on View Model

5 posts, 0 answers
  1. Antonio
    Antonio avatar
    2 posts
    Member since:
    Apr 2013

    Posted 14 May 2013 Link to this post


    I have a RadDataForm that is bound to a collection of records.  This form, when a record is edited should trigger an action in the view model that calls a web service to update the record in a downstream system.  My ultimate challenge is that I do not know how to refer back to the ViewModel (or if it is even possible) from the Custom Command provider.  Any help would be greatly appreciated!

    Code Snippet from my XAML:

            <telerik:RadDataForm Header="Balance Inquiry"
                                 ItemsSource="{Binding BalanceInq}"
                    <commandProvider:IcsManualOpCommandProvider DataForm="{Binding ElementName=IcsManualOpDataForm}"/>

    The Custome Command provider (called IcsManualOpCommandProvider) is defined as follows:
        public class IcsManualOpCommandProvider : DataFormCommandProvider
            public IcsManualOpCommandProvider()
                : base(null)

            protected override void CommitEdit()
                // TODO: call web service

  2. Antonio
    Antonio avatar
    2 posts
    Member since:
    Apr 2013

    Posted 14 May 2013 Link to this post

    Resolved this by registering an Observer against a property of the class bound to the form.  I ensured my CommitEdit() updates this attribute by accessing the object via DataForm.CurrentItem.


  3. DevCraft R3 2016 release webinar banner
  4. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 02 Jul 2013 Link to this post

    I am facing this same issue and would love to see your code solution. I have not used an Observer before.
  5. Daniel B.
    Daniel B. avatar
    18 posts
    Member since:
    Apr 2015

    Posted 30 Jun 2015 Link to this post

    I am facing similar too, though against my code-behind where i will then RaiseEvent

     code example would be great please

  6. Stefan X1
    Stefan X1 avatar
    485 posts

    Posted 03 Jul 2015 Link to this post


    Since you need to access the view model from code-behind, you can use the DataContext of RadDataForm and set a property per your requirements.
    (this.DataForm.DataContext as MyViewModel).MyProperty = //set property value

    Can you please confirm if this fits your requirements?

    Best Regards,
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft R3 2016 release webinar banner