Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
780
How to determine ZIndex order for Gauge Ranges, Needles, TickMarks, etc.
posted

Is there a way to know what Z order items in a gauge will be rendered?  In Silverlight, I'd expect the order they appear in XAML to be the render order, so the last item is rendered last, and therefore on top.  But that doesn't seem to be the way the gauge works. 

In the gauge below, the needle is last.  But it renders below the red and yellow ranges, but above the green (AllowDrag is true, so you can test).

I can manually set the ZIndex, but I'm not sure what value to set it too (100 works in this example), and I'd rather not have to do it manually on all the different items I add to the gauge.  I've seen this same thing with TickMarks as well, so if there's some rules as to how to place items in the gauge to get the expected rendering order, please let me know.

Here's the sample

<igGauge:XamWebRadialGauge>
    <igGauge:XamWebRadialGauge.Scales>
        <igGauge:RadialGaugeScale StartValue="0" EndValue="1000">
            <igGauge:RadialGaugeScale.Ranges>
                <igGauge:RadialGaugeRange StartValue="0" EndValue="300" Fill="Red"
                    InnerExtentStart=".425" InnerExtentEnd=".425" OuterExtent=".635" />
                <igGauge:RadialGaugeRange StartValue="300" EndValue="700" Fill="Yellow"
                    InnerExtentStart=".425" InnerExtentEnd=".425" OuterExtent=".635" />
                <igGauge:RadialGaugeRange StartValue="700" EndValue="1000" Fill="Green"
                    InnerExtentStart=".425" InnerExtentEnd=".425" OuterExtent=".635" />
            </igGauge:RadialGaugeScale.Ranges>
            <igGauge:RadialGaugeScale.Needles>
                <igGauge:RadialGaugeNeedle Background="Black" StartExtent="0" EndExtent=".7" Value="105" AllowDrag="True" />
            </igGauge:RadialGaugeScale.Needles>
        </igGauge:RadialGaugeScale>
    </igGauge:XamWebRadialGauge.Scales>
</igGauge:XamWebRadialGauge>  

Any help is appreciated.

Thanks,
Keith

  • 28496
    Verified Answer
    Offline posted

    i was able to reproduce this problem, so i logged it as a bug and fixed it.  the bug number is 18433.  it should be resolved in an upcoming hotfix; feel free to contact Infragistics Developer Support at any time to inquire about the status of the bug.

    what happened was, I was sorting by ZIndex, but using the List<T>.Sort method, which is an unstable sort, meaning elements with the same ZIndex were not guaranteed to keep their positions.

                    scaleElements.Sort(new Comparison<IHaveZIndex>(delegate(IHaveZIndex one, IHaveZIndex two)
                    {
                        return one.ZIndex.CompareTo(two.ZIndex);
                    }));

    lesson learned, i changed it to use the Linq OrderBy method which uses a stable sort.

                var sorted = scaleElements.OrderBy<IHaveZIndex, int>(el => el.ZIndex);
                scaleElements = new List<IHaveZIndex>(sorted.ToArray());

    as a temporary workaround, you can set the ZIndex to 1 or higher on the needle.