C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Name: I added the Name attribute to the ProgressBar. I chose the short (but not descriptive) Name of "B".
NameExample markup: XAML
<Window x:Class="WpfApplication27.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ProgressBar HorizontalAlignment="Left"
Height="10"
Margin="10,10,0,0"
VerticalAlignment="Top"
Width="100"
Name="B"
Foreground="Salmon"/>
<Button Content="Add"
HorizontalAlignment="Left"
Margin="115,10,0,0"
VerticalAlignment="Top"
Width="75"
Click="Button_Click"/>
</Grid>
</Window>
Example code: C#
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication27
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// ... Add 1/5 to the ProgressBar.
B.Value += (B.Maximum / 5);
// ... See if ProgressBar has reached its max.
if (B.Value == B.Maximum)
{
// ... Change button Content.
Button button = sender as Button;
button.Content = "DONE";
}
}
}
}
And: When the Value equals the maximum of the ProgressBar with name "B", the Button is changed to display "DONE".