Dynamic number of NumberPosition items

4 posts, 0 answers
  1. Miha Markic
    Miha Markic avatar
    48 posts
    Member since:
    Jan 2006

    Posted 17 Dec 2010 Link to this post

    Is there a way to dynamically specify number of NumberPosition items within NumericIndicator in XAML?
  2. Andrey
    Andrey avatar
    1681 posts

    Posted 21 Dec 2010 Link to this post

    Hi Miha Markic,

    In fact the numeric indicator is an items control. So, you can change its positions using the Items property.
    The sample code below adds positions dynamically according to digits of generated value.
    <Window x:Class="DynamicNumberOfPositions.MainWindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid Background="White">
            <Grid Width="200" Height="80">
                <telerik:NumericScale Name="scale"
                                      Min="0" Max="10000">
                        <telerik:NumericIndicator x:Name="numericIndicator"
    using System;
    using System.Windows;
    using System.Windows.Threading;
    using Telerik.Windows.Controls.Gauges;
    namespace DynamicNumberOfPositions
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
            DispatcherTimer timer;
            Random rnd;
            public MainWindow()
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            void MainPage_Loaded(object sender, RoutedEventArgs e)
                rnd = new Random();
                timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromSeconds(1);
                timer.Tick += new EventHandler(timer_Tick);
            void timer_Tick(object sender, EventArgs e)
                double value = rnd.NextDouble() * (scale.Max - scale.Min);
                int intValue = (int)Math.Round(value, 0);
                int positions = intValue.ToString().Length;
                if (positions != numericIndicator.Items.Count)
                    for (int i = 0; i < positions; i++)
                        numericIndicator.Items.Add(new NumberPosition());
                numericIndicator.Value = intValue;

    All the best,
    Andrey Murzov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. DevCraft R3 2016 release webinar banner
  4. pravi
    pravi avatar
    3 posts
    Member since:
    Jul 2011

    Posted 22 Jul 2011 Link to this post


    I have try this but I am not getting the digits, below is my code, please suggest where i am going wrong ?


    if (numericIndicatorIncentives.Items.Count != strCustomerIncentives.Length)
                    for (int i = 0; i < strCustomerCost.Length; i++)
                        NumberPosition numberPosition = new NumberPosition();
                        numberPosition.Margin = new Thickness(2, -1, 0, 1);
                        numberPosition.Background = new SolidColorBrush(Colors.Transparent);
                        numberPosition.FontSize = 24;
                        numberPosition.Height = 45;
                        numberPosition.Width = 23;
                        numberPosition.Background = new SolidColorBrush(Colors.Transparent);
                        numberPosition.BorderBrush = new SolidColorBrush(Colors.Orange);
                        numberPosition.BorderThickness = new Thickness(1);
                        //numberPosition.Background = new Brush();
                        numberPosition.CornerRadius = new CornerRadius (0);
                numericIndicatorIncentives.Value = 100000; //Convert.ToInt32(strCustomerIncentives);
  5. Andrey
    Andrey avatar
    1681 posts

    Posted 27 Jul 2011 Link to this post

    Hello Pravi,

    It is very complicated and is hard for us to reproduce the problemfrom the code snippet you sent. Could you, please, provide us a small sample solution which reproduces it?

    Andrey Murzov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top