How can I find out ZIndex of gauge instrument

Gauge for WPF Forum

Posted 6 years ago by Sasha
Version: 13.1.0583

Hi, I need to find out zIndex of my gauge control. My Xaml code is :

<UserControl x:Uid="UserControl01_Tachometer" 

    <Grid x:Uid="Grid_1" Margin="10" ToolTip="{Binding ToolTip}" ZIndex="{Binding ZIndex, Mode=TwoWay}">
            <RowDefinition x:Uid="RowDefinition_1" Height="Auto" />
            <RowDefinition x:Uid="RowDefinition_2" Height="*" />


 and in my viewModel i have a property, ZIndex. But it never changes. So I would like to know, if I am getting ZIndex in a right way?

Thank you in advance

Comments (5)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA

Hello, I don't really see our controls used in your XAML.  But I assume you are trying to set the ZIndex of your UserControl here?  Setting the Grid's ZIndex won't do anything.  You want to modify the ZIndex of the UserControl instead, so that the z-index of the UserControl changes within its containing panel.  You could that by setting the Panel.ZIndex attached property on the UserControl, perhaps via your binding.

Actipro Software Support

Posted 6 years ago by Sasha

Sorry for my bad Xaml code. Here is my userControl's code:

<Grid x:Uid="Grid_1" Margin="10" ToolTip="{Binding ToolTip}">
            <StackPanel x:Uid="StackPanel_1" Grid.Row="1"  Orientation="Horizontal" 
                    ZIndex="{Binding ZIndex, Mode=TwoWay}"> 
            <Slider x:Uid="ScaleSlider" x:Name="ScaleSlider" Minimum="0.2" Maximum="10" LargeChange="0.5" SmallChange="0.1" 
                    Value="{Binding ScaleSlider}" IsSnapToTickEnabled="True" TickFrequency="0.1" Visibility="Hidden" />

        <ScrollViewer x:Uid="ScrollViewer_1" Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <Border x:Uid="AlStatusBorder" BorderBrush="#101010" BorderThickness="3"
                    Background="{Binding Color}"
                    CornerRadius="10" HorizontalAlignment="Center" VerticalAlignment="Top"
                <Grid x:Uid="Grid_2">
                    <!-- Tachometer Gauge -->
                    <gauge:CircularGauge x:Uid="gauge:CircularGauge_1" Grid.Row="1" Grid.Column="2" FrameType="CircularTopGradient" Width="150" Height="150" Radius="75" Background="#444444"
                                         ZIndex="{Binding ZIndex, Mode=TwoWay}">
                        <gauge:CircularGauge.LayoutTransform >
                            <ScaleTransform x:Uid="ScaleTransform_1" ScaleX="{Binding ElementName=ScaleSlider, Path=Value}"
                                    ScaleY="{Binding ElementName=ScaleSlider, Path=Value}"/>
                            <TextBlock x:Uid="AlMessgroesse1" gauge:CircularGauge.X="0" gauge:CircularGauge.Y="-18" Text="{Binding MeasuredValue}" x:Name="AlMessgroesse1"
                                    Foreground="WhiteSmoke" FontSize="8" />
                            <TextBlock x:Uid="AlMessEinheit1" gauge:CircularGauge.X="0" gauge:CircularGauge.Y="20" Text="{Binding UnitOfMeasure}" Foreground="WhiteSmoke" x:Name="AlMessEinheit1"
                                    FontSize="8" />
                            <TextBlock x:Uid="AlXScalFactor" gauge:CircularGauge.X="0" gauge:CircularGauge.Y="33" Text="{Binding ScaleFactor}" 
                                       Foreground="WhiteSmoke" x:Name="AlXScalFactor"
                                    FontSize="8" RenderTransformOrigin="-1,0.5" />

                            <!-- Tachometer -->
                            <gauge:CircularScale x:Uid="AlCircularScale1" Radius="64" StartAngle="110" SweepAngle="320" BarExtent="5" IsBarVisible="False" x:Name="AlCircularScale1"
                                    Background="{shared:LinearGradientBrush Gray, DarkGray, GradientType=TopToBottom}" 
                                                 ZIndex="{Binding ZIndex, Mode=TwoWay}">
                                       <gauge:CircularTickSet Minimum="{Binding MinimumScaleValue}" Maximum="{Binding MaximumScaleValue}"
                                                           MajorInterval="{Binding MajorInterval}" MajorIntervalType="Auto"
                                                           MinorInterval="{Binding MinorInterval}" MinorIntervalType="Auto"
                                                           IsLogarithmic="{Binding IsLogarithmic}"
                                                           LogarithmicBase="{Binding LogarithmicBase}" IntervalOrigin="Minimum"
                                                           ZIndex="{Binding ZIndex, Mode=TwoWay}" >

                                            //Here are code for ranges
                                            //Here are code for ticks
                                            //Code for pointer

 As I understood, userControl should have somewhere property with ZIndex value. As you can see, I tried to use ZIndex from different places, but ZIndex in my viewModel is always zero. And I can't find any example of using ZIndex in Actipro. Should I get ZIndex from my userControl, or from some other place?

Thank you

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA

Sorry but I'm still not quite sure what you are trying to accomplish.  Panel.ZIndex is an attached property that some Panels use to determine how to layer their direct child controls.  So for example, a Grid would use it to determine the z direction layering of the controls in its Children collection.

If you are putting the entire UserControl in a Panel of some sort and you are trying to set its z-index within that Panel, then you'd do Panel.ZIndex="{Binding ZIndex, Mode=TwoWay}" on the UserControl tag itself.

Actipro Software Support

Posted 6 years ago by Sasha

I am creating dynamically gauge controls. Then I want to save created controls to database. When the program will be run next time, I want to load this contols from database. So I need to know ZIndex of each control, to load them correctly.

I thought that I am able to bind ZIndex property of each control to property in my viewModel, but I should find ZIndex property via Panel, where all my controls are located, right? 

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA

If you mean the entire UserControl is what you are calling a "gauge control" then you would want to persist the Panel.ZIndex attached property of it.  Again, this is assuming you have multiple UserControls stacked somehow in a containing Panel.

That being said, the Panel.ZIndex attached property might be 0 for all the UserControls in your Panel, unless you explicitly are setting it somewhere.  Here is a good article that explains z-order:

Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 14 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.