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

ZIndex bindings are ignored

5 Answers 206 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 13 Aug 2012, 08:17 PM
This is a bit odd, as I would expect binding changes would be respected.  I'm not sure if it is a bug or not, but its definitely unexpected.

ZIndex is a DependencyProperty of the RadDiagramItem class.  Being read/write, I would expect that changes to the ZOrder would be reflected in the RadDiagram.  This is not the case.

If this is recognized as a bug, I have a repro project I can send along.

Given a type ModelItem with the following DependencyProperties:  Position, Width, Height, Color, and ZIndex (I'll omit that code as it is lengthy).

I have a custom graph which implements IGraphSource<ModelItem>, IObservableGraphSource (again, omitted for space) which I add three items to, which match the example found here.

public MainWindow()
{
    InitializeComponent();
    var graph = new TemplateGraph();
    graph.AddNode(new ModelItem
    {
        ZIndex = 3,
        Position = new Point(80, 120),
        Width = 150,
        Height = 150,
        Color = Colors.Red
    });
    graph.AddNode(new ModelItem
    {
        ZIndex = 2,
        Position = new Point(180, 120),
        Width = 150,
        Height = 150,
        Color = Colors.Green
    });
    graph.AddNode(new ModelItem
    {
        ZIndex = 1,
        Position = new Point(120, 20),
        Width = 150,
        Height = 150,
        Color = Colors.Blue
    });
    diagram.GraphSource = graph;
}

In the UI, I have a style which binds the relevant properties of each ModelItem to a RadDiagramShape.  

<Window.Resources>
    <Style
        TargetType="telerik:RadDiagramShape">
        <Setter
            Property="Position"
            Value="{Binding Position}" />
        <Setter
            Property="IsConnectorsManipulationEnabled"
            Value="False" />
        <Setter
            Property="Background">
            <Setter.Value>
                <SolidColorBrush
                    Color="{Binding Color}" />
            </Setter.Value>
        </Setter>
        <Setter
            Property="Geometry"
            Value="{telerik:CommonShape ShapeType=EllipseShape}" />
        <Setter
            Property="Width"
            Value="{Binding Width, Mode=TwoWay}" />
        <Setter
            Property="Height"
            Value="{Binding Height, Mode=TwoWay}" />
        <Setter
            Property="ZIndex"
            Value="{Binding ZIndex, Mode=TwoWay}" />
            <Setter
                Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock
                            Text="{Binding ZIndex}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
</Window.Resources>

Note that the shape's NormalContent displays the ZIndex.

Finally, I have a RadNumericUpDown that controls the ZIndex of the SelectedItem in the RadDiagram

<DockPanel>
    <telerik:RadNumericUpDown
        Value="{Binding SelectedItem.ZIndex, ElementName=diagram}" />
    <telerik:RadDiagram
        x:Name="diagram" />
</DockPanel>

I'll attach a screenshot that shows that, even though the ZIndex has changed, the order of shapes on the diagram has not.  In the screenshot, you can see that everything appears as it should be -- the ZIndexes of my models are correctly reflected in bindings of the RadDiagramShape, selection bindings work, and changes in the RadNumericUpDown are reflected in the bindings.

However,  changes to RadDiagramItem.ZIndex are completely ignored by the RadDiagram, both when initially added, and forever thereafter.  What's the point of the ZIndex property when it doesn't work?

If bug, you are hereby notified.  If not, you need this feature request.  Either way, I could use some help with a workaround.

5 Answers, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 15 Aug 2012, 03:07 PM
Hi Will,

 After deep investigation I found out that the ZIndex Style binding gets disconnected because we assign the ZIndex property in our Shape's constructor. This is needed because the Shapes and the Connections have different ZIndicies. I consider this as an issue and so I created a work item for it. It should be fixed soon for some of the minor releases.
On a side note, you can use the DiagramItem's ZIndex directly or you can use our Commands or Methods - BrindForward and so on. 
Sorry for any inconvenience. 
I've also updated your Telerik points. 

All the best,
Miro Miroslavov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Derrick
Top achievements
Rank 1
answered on 27 Sep 2012, 09:01 PM
Is there a timeline for this issue to be fixed? I checked in the latest internal build and the bug is still there.
0
Miro Miroslavov
Telerik team
answered on 29 Sep 2012, 07:27 AM
Hi Derrick,

 The issue is not scheduled yet, but we'll do our best to fix it for our incoming in a few weeks Q3.2012 release.
Hope this time frame is ok for you. 

All the best,
Miro Miroslavov
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Petar Mladenov
Telerik team
answered on 18 Oct 2012, 01:43 PM
Hi Derrick,

This issue is now resolved in Q3 2012. We highly encourage to upgrade and also try the new Diagramming features - Gliding Connectors (could be seen in the Class Diagram Demo), Drawing Features, ShapeContainers (could be seen in FirstLookDemo), Export To HTML.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Andi
Top achievements
Rank 1
commented on 04 Oct 2021, 02:43 PM

Hi there,

we want to build different layers of diagram shapes - placeholders on one layer where other shapes on higher layers might be dropped and their layout fits the placeholder.

What is the best practice to set a fix ZOrder (not changed by diagram) ?

Thank you, Andi

0
Petar Mladenov
Telerik team
answered on 06 Oct 2021, 08:37 AM

Hi Andi,

ZIndex is generally set in Styles so that all shapes have ZIndex 2, all connections have ZIndex 1 and all containers have ZIndex 0. The best way to organize your layers is that you have property in your ViewModel which can be bound to the ZIndex of the RadDiagramShape via style setter. For example all models in Layer A have ZIndex 1, all models from Layer B have zIndex 2, etc.

On a side note, if your requirement is more complex, I would encourage you to open a new support ticket since this thread is too old and it might become unrelated. Also , it will be easier for our support team to address your requirement. Thank you for your understanding.

Regards,
Petar Mladenov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Diagram
Asked by
Will
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Derrick
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or