This is a migrated thread and some comments may be shown as answers.

Custom shape and MVVM

4 Answers 246 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 15 Nov 2012, 03:08 PM
Hi'
I would like to use custom shapes together with MVVM. I have followed the online documentation regarding MVVM and RadDiagram:
http://www.telerik.com/help/wpf/raddiagrams-howto-mvvm.html
But I do not know how to create custom shapes when using MVVM - could you please provide an example?
Thanks,
Michael

4 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 20 Nov 2012, 12:43 PM
Hello Michael,

 It is possible to use Custom Shapes in MVVM scenario. Actually this is demonstrated in our MindMap and OrgChart samples. The key moments in this requirement are:
 1) Inherit the RadDiagramShapeBase and create custom Shape like in this help article
 2) Inherit the RadDiagram and override the following methods:

protected override Telerik.Windows.Diagrams.Core.IShape GetShapeContainerForItemOverride(object item)
{
    return ShapeSelector.GetShape(item);
}
 
protected override bool IsItemItsOwnShapeContainerOverride(object item)
{
    return item is MindmapShapeBase;
}

The GetShapeContainerForItemOverride method is the place where you can return Custom Shape or default Shape depending on your ViewModel.
 3) Use Style Selector to return a Style depending on the type of the business object.

You can find these steps implemented in the attached project as well. Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 1
answered on 21 Nov 2012, 02:00 PM
Thanks! Most helpful

Michael
0
Kavita
Top achievements
Rank 1
answered on 17 Apr 2013, 06:08 AM
Hey!!

I need to create a wpf diagram designer which consist multiple layers design (user can add layers according to need and can switch among layers and can also show/ hide layers) and each layer can have different diagram but they are party of single design. Now my question is that how we can create multiple layers like we have different layers in photoshop where layers are used to work on individual parts of an image while not affecting other parts. And the same thing I have to create in wpf diagram designer .....

0
Tina Stancheva
Telerik team
answered on 19 Apr 2013, 02:37 PM
Hello Kavita,

As Lancelot explained in this forum post, the RadDiagram don't provide layers out-of-the-box but you can easily create custom layers by applying different ZIndex settings on the different shapes. Once you create your layers of shapes, you can mark each shape in order to know the layer it belongs to (you can use DataBinding and business values to differentiate the layers and the shapes or simply use the Tag property of the shapes). Once you can tell the layer in which a shape belongs, you can traverse the RadDiagram shapes collection and find all shapes of a certain layer to hide or display them together.

Please let us know if this information helps.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Michael
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Michael
Top achievements
Rank 1
Kavita
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or