How to get radial gauge needle to move

2 posts, 0 answers
  1. Jeffrey
    Jeffrey avatar
    1 posts
    Member since:
    Dec 2010

    Posted 21 Dec 2010 Link to this post

    hello,
    i am new to SL development. i have bulit a SL navigation project and placed a radial gauge in it. can you please show me how to pass values to the gauge that makes the needle move  in the code behind.
    thanks

    home.xaml code
      
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:telerik=http://schemas.telerik.com/2008/xaml/presentation
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    Title="Home"
      
    Style="{StaticResource PageStyle}">
      
    <Grid x:Name="LayoutRoot">
      
    <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
      
    <StackPanel x:Name="ContentStackPanel">
      
    <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" 
      
    Text="Home"/>
      
    <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" 
      
    Text="Home page content"/>
      
      
    <!--main RadGauge root container --> 
      
    <telerik:RadGauge Name="radGauge" Width="300" Height="300">
      
    <!-- Add RadialGauge container to the internal RadGauge layout. -->
      
    <telerik:RadialGauge>
      
    <!-- Now you can insert RadialScale object into the radial gauge container for further configuration. For example, you can set Min and Max properties of the scale: -->
      
    <telerik:RadialScale Name="radialScale" Min="0" Max="1000">
      
    <!-- The last object you have to add is indicator (for example, needle indicator). You have to insert the list of the indicators to the radial scale object and then add needle indicator there: -->
      
    <telerik:IndicatorList>
      
      
    <telerik:Needle Name="needle" Value="100"/>
      
      
    </telerik:IndicatorList>
      
    </telerik:RadialScale>
      
    </telerik:RadialGauge>
      
    </telerik:RadGauge>
      
      
    </StackPanel>
      
    </ScrollViewer>
      
    </Grid>
      
    </navigation:Page>
      
    home.xaml.cs
      
      
      
    using System;
      
      
    using System.Collections.Generic;
      
      
    using System.Linq;
      
      
    using System.Net;
      
      
    using System.Windows;
      
      
    using System.Windows.Controls;
      
      
    using System.Windows.Documents;
      
      
    using System.Windows.Input;
      
      
    using System.Windows.Media;
      
      
    using System.Windows.Media.Animation;
      
      
    using System.Windows.Navigation;
      
      
    using System.Windows.Shapes;
      
      
    //you have to add telerik using here
      
      
    using Telerik.Windows.Controls.Gauges;
      
      
    using Telerik.Windows.Controls;
      
      
      
    namespace thermometerNavigation
      
    {
      
    public partial class Home : Page
      
      
    {
      
    public Home()
      
    {
      
    InitializeComponent();
      
      
    }
      
    // Executes when the user navigates to this page.
      
      
    protected override void OnNavigatedTo(NavigationEventArgs e)
      
    {
      
    }
      
    }
      
    }
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 23 Dec 2010 Link to this post

    Hello Jeffrey,

    You can simply assign new value to the Value property of the needle to move it to different position. In your C# code you can do it for example using the Loaded event.
    public Home()
    {
        InitializeComponent();

        
    Loaded += new RoutedEventHandler(Home_Loaded);
    }

    void
    Home_Loaded(object sender, RoutedEventArgs e)
    {
        this.needle.Value = 500d;
    }

    All the best,
    Andrey Murzov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top