Untitled
unknown
plain_text
2 years ago
2.3 kB
7
Indexable
<Window x:Class="YourNamespace.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ig="http://schemas.infragistics.com/xaml"
Title="Circular Progress Bar" Height="300" Width="300">
<Grid>
<ig:XamRadialGauge x:Name="circularProgressBar" Width="150" Height="150">
<ig:XamRadialGauge.ArcStartAngle>0</ig:XamRadialGauge.ArcStartAngle>
<ig:XamRadialGauge.ArcEndAngle>
<Binding Path="Progress" Converter="{StaticResource ProgressToAngleConverter}" />
</ig:XamRadialGauge.ArcEndAngle>
<ig:XamRadialGauge.Scales>
<ig:RadialGaugeScale MinimumValue="0" MaximumValue="100"
StartAngle="-150" EndAngle="150" />
</ig:XamRadialGauge.Scales>
<ig:XamRadialGauge.Needles>
<ig:RadialGaugeNeedle Value="{Binding Progress}" />
</ig:XamRadialGauge.Needles>
</ig:XamRadialGauge>
</Grid>
</Window>
using System.ComponentModel;
public class ViewModel : INotifyPropertyChanged
{
private double progress;
public double Progress
{
get { return progress; }
set
{
if (progress != value)
{
progress = value;
OnPropertyChanged("Progress");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public partial class MainWindow : Window
{
private ViewModel viewModel;
public MainWindow()
{
InitializeComponent();
viewModel = new ViewModel();
DataContext = viewModel;
// Simulate progress updates (for testing purposes)
var timer = new System.Windows.Threading.DispatcherTimer();
timer.Tick += (s, e) =>
{
if (viewModel.Progress < 100)
viewModel.Progress += 5;
else
timer.Stop();
};
timer.Interval = TimeSpan.FromSeconds(1);
timer.Start();
}
}
Editor is loading...