Hi I am trying to set up a progress bar with some text and a button to cancel, so I used a user control. I created properties to this user control (Min,Max,Value) to pass them to the internal progress bar. It works when I initialize my user control with these values but when I update the value the progress bar doesn't move. Does anyone have any idea why ? Of course, the work represented by the progress bar is done on a seperate thread and the values are indeed updated and goes from 0 to 100.
XAML
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<ProgressBar x:Name="progress_bar_internal" Minimum="{Binding Min}" Maximum="{Binding Max}" Value="{Binding Value}" Foreground="DarkGreen" Height="{Binding Height}" VerticalAlignment="Center"/>
<TextBlock Text="{Binding ElementName=progress_bar_internal, Path=Value, StringFormat={}{0:0}%}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>
<wpfui:Button Icon="PaneClose24" Grid.Column="1" VerticalAlignment="Center" Height="{Binding Height}" x:Name="cancel_btn" Background="DarkRed"/>
</Grid>
The code behind
public partial class ProgressBar_w_Text : UserControl
{
public ProgressBar_w_Text()
{
InitializeComponent();
this.DataContext = this;
}
public event RoutedEventHandler Click
{
add { cancel_btn.AddHandler(ButtonBase.ClickEvent, value); }
remove { cancel_btn.RemoveHandler(ButtonBase.ClickEvent, value); }
}
public int Value { get; set; }
public int Max { get; set; }
public int Min { get; set; }
}
Call
<uc:ProgressBar_w_Text Visibility="Collapsed" x:Name="progress_bar" Height="50" Click="cancel_patcher" Min="0" Max="100" Value="15"/>