title: c# wpf Progress bar in different window
body: <p>I am trying to figure out how to use a progress bar in my application. I have a logoff form as mainwindow. And i want a additional window for the progress bar. In my mainwindow code there is a 15 second sleep. I would like the user to see the progress in a progressbar and if the 15 seconds are finished the progressbar needs to close. I want to know if there is any way for me to put the code of the progress bar in my mainwindow code. Or maybe a way to let the progress bar interact with the 15 second wait time.</p>
  
  <p>Im new to coding so explaining the code is very helpfull for me to understand the code.</p>
  
  <p>thanks in advance.</p>
  
  <p>my code in the progressbar window:</p>
  
  <pre><code>public partial class ProgressBar : Window
      {
          public ProgressBar()
          {
              InitializeComponent();
          }
  
          private void Window_ContentRendered(object sender, EventArgs e)
          {
              for (int i = 0; i &lt;= 15; i++)
              {
                  pbStatus.Value++;
                  System.Threading.Thread.Sleep(1000);
              }
          }
      }
  </code></pre>
  
  <p>my progressbar.xaml:</p>
  
  <pre><code>&lt;Window x:Class="Sessie_Afmeld_Applicatie.ProgressBar"
           WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:Sessie_Afmeld_Applicatie"
          mc:Ignorable="d"
          Title="Voortgang" Height="100" Width="300"&gt;
      &lt;Grid&gt;
          &lt;ProgressBar Minimum="0" Maximum="150" Name="pbStatus"  Margin="25,23,37,23" Foreground="#FF13B931" ValueChanged="pbStatus_ValueChanged"   /&gt;
          &lt;Label Content="Label" HorizontalAlignment="Left" Margin="125,66,0,0" VerticalAlignment="Top"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>