Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a basic example of using the RadRadialGauge.</p> <hr> <h2>XAML:</h2> <hr> <pre><code>&lt;telerik:RadRadialGauge x:Name="radialGauge" Width="300" Height="300" Grid.Column="0"&gt; &lt;telerik:RadialScale Min="1" Max="12"&gt; &lt;telerik:RadialScale.Indicators&gt; &lt;telerik:Needle x:Name="needle" /&gt; &lt;telerik:Pinpoint/&gt; &lt;/telerik:RadialScale.Indicators&gt; &lt;/telerik:RadialScale&gt; &lt;/telerik:RadRadialGauge&gt; </code></pre> <p>As you can see i have a radial gauge with a radial scale defined. Radial Scale has a needle as the indicator. The RadialScale is from 1 to 12. Note that i have given a name for the needle. We will use this to push values from the code behind. </p> <p>In this example i am using a dispatcher timer to tick every 1 second and i am generating a random value between 1 to 12. Here is the code behind snippets.</p> <hr> <h2>code snippet:</h2> <hr> <p>Following variables are declared at the window level</p> <pre><code>TimeSpan interval = TimeSpan.FromSeconds(1); DispatcherTimer timer; Random rnd = new Random(); </code></pre> <p>I have defined event handlers for Window Loaded &amp; Unloaded events. On Window Load, i start the timer.</p> <pre><code> void OnWindowLoad(object sender, RoutedEventArgs e) { timer = new DispatcherTimer(); timer.Interval = interval; timer.Tick += new EventHandler(Timer_Tick); timer.Start(); } </code></pre> <p>Here is the timer tick function:</p> <pre><code> private void Timer_Tick(object sender, EventArgs e) { timer.Stop(); SetNextValue(); timer.Start(); } </code></pre> <p>Here is the SetNextValue function:</p> <pre><code> private void SetNextValue() { int minValue = 1; int maxValue = 12; int nextValue = rnd.Next(minValue, maxValue); needle.Value = nextValue; } </code></pre> <p>In the Unloaded event handler i am stopping the timer.</p> <pre><code> void OnWindowUnload(object sender, RoutedEventArgs e) { timer.Stop(); } </code></pre> <p>Output: when you run the app, you will see the needle changing its position because we are generating random numbers from 1 to 12 every second and we set the generated number to needle's value. The SetNextValue() method can be your gateway to monitoring the real value and set the needle value to that real data.</p> <p>This is the basic example code i can think of to explain the radial gauge.</p> <p>Hope this provides the answer you are looking for.</p> <hr> <h2>Update:</h2> <hr> <p>Here is an MVVM way of setting the needle value. Let the window implement INotifyPropertyChanged interface. Set the datacontext to the window itself</p> <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged public MainWindow() { InitializeComponent(); Loaded += OnWindowLoad; Unloaded += OnWindowUnload; DataContext = this; } </code></pre> <p>Provide implementation for the PropertyChanged event like below:</p> <pre><code>public event PropertyChangedEventHandler PropertyChanged = delegate { }; void NotifyPropertyChanged(string propName) { PropertyChanged(this, new PropertyChangedEventArgs(propName)); } </code></pre> <p>Implement a property called NeedleValue.</p> <pre><code> int needleValue = 1; public int NeedleValue { get { return needleValue; } set { needleValue = value; NotifyPropertyChanged("NeedleValue"); } } </code></pre> <p>In the SetNextValue - just set the newly created NeedleValue property. this will fire the property changed notification.</p> <pre><code>private void SetNextValue() { int minValue = 1; int maxValue = 12; int nextValue = rnd.Next(minValue, maxValue); NeedleValue = nextValue; } </code></pre> <p>In the XAML bind the Needle Value property to NeedleValue like below</p> <pre><code>&lt;telerik:Needle x:Name="needle" Value="{Binding NeedleValue}" /&gt; </code></pre> <p>Hope this provides you with the answer you are looking for :)</p> <p>Lohith (Tech Evangelist, Telerik India)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload