MVVM Command support - suggestion

4 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 02 Jul 2014 Link to this post

    Hi,

    over the year more and more things have become "bindable" - a must have for MVVM.
    What I still miss is Command Support.

    Example - RadGridView.
    I need special logic to store (insert / update) a row in the database.

    What I have to do is handle the RowEditEnded (and if I need RowValidation) also the RowValidating events.

    I solved this by subclassing the RadGridView and offering a "RowEditEndedCommand" and a "RowValidatingCommand" as ICommand.

    Now I can handle the things without code behind.
    Something like <xx:MyGridView RowEditEndedCommand="{Binding MySpecialCommand}"...

    And what I got is a thing like a Button - I still can handle Events (OnClick) - but I can also bind a Command from my VM.

    I don't know if I'm the only one with this need....

    Manfred
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 04 Jul 2014 Link to this post

    Hello Manfred,

    Generally, you can combine events and commands through EventToCommandBehavior. More information about it can be found in our documentation explaining how you could benefit from it. 
    Does this approach meet your requirements ? 

    Regards,
    Maya
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 04 Jul 2014 in reply to Maya Link to this post

    Hi Maya,

    I know about this option and my post was just a suggestion.

    Using the behavior is like using glue to add an (in MVVM) always needed handle.
    While (what I suggested) the manufacturer could ship the product with a handle already attached.

    Something like the IsReadonlyBinding on a GridViewDataColumn - of course I could mess around with ancestor bindings and so..
    But you provided this very helpful property - which keeps the XAML clean and makes the things a lot easier.

    Manfred
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Jul 2014 Link to this post

    Hi Manfred,

    As far as I understand, you suggest to have a Command for each event that RadGridView provides. This does sound like a good idea, but the thing is that there are quite a lot of events and it might be a bit overwhelming to have both events and commands connected to them since we do have an EventToCommandBehavior. 
    Nevertheless, I will talk with the team to verify if this is something we would do. Thank you for the feedback.


    Regards,
    Maya
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top