"Cannot modify the Items collection when the GraphSource is set"

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

    Posted 20 Dec 2012 Link to this post


    <RadDiagram ...>
    <primitives:GraphPaper />
    </RadDiagram ...>

    That tag causes an exception to be thrown:

    A first chance exception of type 'System.InvalidOperationException' occurred in Telerik.Windows.Controls.Diagrams.dll

    Additional information: Cannot modify the Items collection when the GraphSource is set.

    What's up?

  2. Petar Mladenov
    Petar Mladenov avatar
    2986 posts

    Posted 21 Dec 2012 Link to this post

    Hi Kristoffer,

     The GraphPaper should not be used as a "child" element of the RadDiagram. In a typical ItemsControl, when something is added as a child in XAML, it is wrapped to the corresponding Container. If you use ListBox, the added object will be wrapped to ListBoxItem, for instance. Analogically, RadDiagram will wrap the object to RadDiagramShape. But you can never have both bound items generated via ItemsSource and a static ones in XAML. The analogical system exception in a System Control will be:
    "Cannot modify the Items collection when the DataSource is set" (or something very similar).
    On the other hand, do you really need to use the GraphPaper stand alone ? Actually you can set it with a single property - IsBackGroundSurfaceVisible. You can find more info here.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top