How can I find out ZIndex of gauge instrument

Gauge for WPF Forum

Posted 11 years ago by Sasha
Version: 13.1.0583
Avatar

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

<UserControl x:Uid="UserControl01_Tachometer" 
             x:Class="Auswertung.UserControls.UserControl01_Tachometer.UserControl01"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:gauge="http://schemas.actiprosoftware.com/winfx/xaml/gauge"
             xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
             x:Name="UserControl01Tachometer"
             >

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

     </Grid>
</UserControl>

 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 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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 11 years ago by Sasha
Avatar

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" />
        </StackPanel>

        <ScrollViewer x:Uid="ScrollViewer_1" Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <Border x:Uid="AlStatusBorder" BorderBrush="#101010" BorderThickness="3"
                    Background="{Binding Color}"
                    x:Name="AlStatusBorder"
                    Padding="5"
                    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"
                            RimBrush="#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}"/>
                        </gauge:CircularGauge.LayoutTransform>
                        <gauge:CircularGauge.Items>
                            <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" />
                           
                        </gauge:CircularGauge.Items>

                        <gauge:CircularGauge.Scales>
                            <!-- 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:CircularScale.TickSets>
                                       <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"
                                                           x:Name="AlScaleTickSet1" 
                                                           ZIndex="{Binding ZIndex, Mode=TwoWay}" >
                                        
                                        <gauge:CircularTickSet.Ranges>

                                            //Here are code for ranges
                                        </gauge:CircularTickSet.Ranges>
                                        <gauge:CircularTickSet.Ticks>
                                            //Here are code for ticks
                                         </gauge:CircularTickSet.Ticks>
                                        <gauge:CircularTickSet.Pointers>
                                            //Code for pointer
                                        </gauge:CircularTickSet.Pointers>
                                    </gauge:CircularTickSet>
                                </gauge:CircularScale.TickSets>
                            </gauge:CircularScale>
                        </gauge:CircularGauge.Scales>
                    </gauge:CircularGauge>
                </Grid>
            </Border>
        </ScrollViewer>
    </Grid>

 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 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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 11 years ago by Sasha
Avatar

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 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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:

http://blogs.msdn.com/b/wpfsdk/archive/2006/06/13/controlling-zorder-using-the-zindex-property.aspx


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.