I am trying to update my progress bar inside contentrendered(object sender, EventArgs e)
event. This is my code :-
MainWindow.xaml.cs
DynamicControls.ProgressBarWindow _progressBarWindow = new DynamicControls.ProgressBarWindow("Please Wait...");
_progressBarWindow.ShowDialog();
XAML
<Window x:Class="nk_Image_Converter.DynamicControls.ProgressBarWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ProgressBarWindow" Height="100" Width="500" BorderThickness="0" WindowStyle="None" ResizeMode="NoResize" Background="#d4dce6" Loaded="Window_Loaded" Initialized="Window_Initialized" ContentRendered="Window_ContentRendered" LayoutUpdated="Window_LayoutUpdated" Activated="Window_Activated" >
<Window.Effect>
<DropShadowEffect Opacity="0.4"/>
</Window.Effect>
<Border BorderBrush="CadetBlue" BorderThickness="3,0,3,3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="CadetBlue"></Grid>
<Grid Grid.Row="1" Background="Transparent">
<Label x:Name="Message" Content="Please Wait..." Margin="42,15"/>
<ProgressBar x:Name="Progressbar" Width="400" Height="25" Margin="47,38,47,14" Foreground="CadetBlue" BorderBrush="CadetBlue" BorderThickness="2"></ProgressBar>
</Grid>
</Grid>
</Border>
C#
private void Window_ContentRendered(object sender, EventArgs e)
{
for(//Some Condition//)
{
Some Stuff
Thread.sleep(100);
this.ProgressBar.Value = //Some Value
// above statement doesn't update the progressbar instantly
}
}
In the code above, I want the progress Bar to move as I give a Value every time inside for loop, but it gets updated when the event get completed.