RoutingService readonly?!

5 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 21 Jan 2013 Link to this post

    In XAML, I try to bind the RoutingService of my diagram:

    <telerik:RadDiagram ....... RoutingService="{Binding Router}" ... />

    And I get this error:

    'RoutingService' property is read-only and cannot be set from markup. Line 92 Position 45.

    Why do I have to assign this router in code-behind? Makes sense to bind it since it can easily be a property of my viewmodel...

    UPDATE: Basically, I'm trying to assign the Router to an instance of OrgTreeRouter.

  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 24 Jan 2013 Link to this post

    Hi Kristoffer,
    The RoutingService property of the RadDiagram has only a getter and that's why you can't bind it. In Q1 2013 we'll include a way to change the default services but you'll still have to do it in code-behind because we don't want to expose dependency properties for all of them.
    For now your only solution is to change the Router in code behind.
    I hope I was able to help your and if you have further please feel free to ask.

    All the best,
    Zarko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 24 Jan 2013 Link to this post

    Thanks.

    Recall my post regarding MVVM:
    http://www.telerik.com/community/forums/wpf/general-discussions/which-of-your-controls-are-suitable-for-mvvm.aspx

    In MVVM the view is not aware of the viewmodel. If I need to have my router in my viewmodel, the necessary code-behind will effectively undo the decoupling of the view and the viewmodel:

    var viewModel = DataContext as MyViewModel;
    this.diagram.RoutingService.Router = viewModel.Router;

    We keep running into issues like this when playing with RadDiagram. Hence, I would argue that RadDiagram is not suitable for MVVM.
  5. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 24 Jan 2013 Link to this post

    Hi Kristoffer,

     Thank you for your valuable feedback. We are heavily trying to make RadDiagram fully MVVM-able. But you should understand that this is not really possible in all cases. MVVM in its purest variant is a myth. Different "workarounds" have appeared during the years that made MVVM possible in most of the scenarios like Behaviors (EventToCommand), Messaging systems, Selectors and what not. I blogged about this some time ago.
    Also you should note that RadDiagram is not just a control, but a Framework that has lots of functionality and I would say that is nearly impossible to expose every single bit as Dependency property. All these internal services and infrastructure things are more part of the Diagramming API and not just the control.
    For example if we expose RoutingService DP, this will mean that you should be able to define new Service of that type in XAML?
    I hope you will understand my concerns. Hope this is not a showstopper for you.

    Greetings,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 24 Jan 2013 Link to this post

    Excellent answer. Thank you!

    I will read your blog entry! MVVM certainly is painful sometimes, and I understand not everything can be solved using this pattern.
Back to Top
UI for WPF is Visual Studio 2017 Ready