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

Set LineSeries ZIndex in Style Trigger

1 Answer 86 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Veteran
Brandon asked on 20 Mar 2021, 07:49 PM
I have several LineSeries on a RadCartesianPlot.  When the user selects one of the series, I want to ensure that series is drawn on top of the others, so I would like to set its ZIndex property in a Style Trigger like this:

<Style TargetType="telerik:LineSeries">
    <Style.Triggers>
        <Trigger Property="IsSelected"
                 Value="True">
            <Setter Property="ZIndex"
                    Value="999"/>
        </Trigger>
    </Style.Triggers>
</Style>

However, I cannot set the ZIndex property via a Setter because it is not a DependencyProperty.  This post (https://www.telerik.com/forums/setting-zindex-when-using-chartseriesprovider) has a similar issue, and the recommended solution is to create an attached property, but this seems like something that should "just work".  In fact, some other posts show setting the ZIndex in a Setter as if it should work (https://www.telerik.com/forums/seriesprovider-and-series-display-order).  Can the ZIndex property be changed to a DependencyProperty so we don't have to implement a workaround to use it in a Trigger?

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Mar 2021, 11:17 AM

Hello Brandon,

Thank you for the provided code snippet.

You are right that the ZIndex property can't be set in XAML or bind. Your suggestion is meaningful and I have logged a feedback item in our Feedback portal to convert this property to dependency property. You can vote for it so that you can get notified of its status changed and increase its priority.

I will update my reply in the mentioned forum thread as I have overlooked this behavior. Your Telerik Points are updated for bringing this to our attention.

An approach that you could try is to use the SelectionChanged event. This event will be trigger when a data point is selected. In the event handler, you can get the selected point and its series. From here, bring the series up to from by setting its ZIndex property.

private void ChartSelectionBehavior_SelectionChanged(object sender, Telerik.Windows.Controls.ChartView.ChartSelectionChangedEventArgs e)
{
    var addedDataPoint = e.AddedPoints[0];
    var series = addedDataPoint.Presenter as LineSeries;
    series.ZIndex = 100;
}

I hope this approach will work for you.

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ChartView
Asked by
Brandon
Top achievements
Rank 1
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or