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.
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()
{
InitializeComponent();
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);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
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)
{
numericIndicator.Items.Clear();
for (int i = 0; i < positions; i++)
{
numericIndicator.Items.Add(new NumberPosition());
}
}
numericIndicator.Value = intValue;
timer.Start();
}
}
}
All the best,
Andrey Murzov
the Telerik team
Browse the
videos here>> to help you get started with RadControls for WPF