diff --git a/MahApps.Metro/Controls/Dialogs/ProgressDialog.cs b/MahApps.Metro/Controls/Dialogs/ProgressDialog.cs
index a4ad997d55..ccf522afd4 100644
--- a/MahApps.Metro/Controls/Dialogs/ProgressDialog.cs
+++ b/MahApps.Metro/Controls/Dialogs/ProgressDialog.cs
@@ -29,6 +29,7 @@ internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings)
ProgressBarForeground = Brushes.White;
}
}
+
internal ProgressDialog(MetroWindow parentWindow)
: this(parentWindow, null)
{ }
@@ -69,5 +70,33 @@ internal CancellationToken CancellationToken
{
get { return DialogSettings.CancellationToken; }
}
+
+ internal double Minimum
+ {
+ get { return PART_ProgressBar.Minimum; }
+ set { PART_ProgressBar.Minimum = value; }
+ }
+
+ internal double Maximum
+ {
+ get { return PART_ProgressBar.Maximum; }
+ set { PART_ProgressBar.Maximum = value; }
+ }
+
+ internal double ProgressValue
+ {
+ get { return PART_ProgressBar.Value; }
+ set
+ {
+ PART_ProgressBar.IsIndeterminate = false;
+ PART_ProgressBar.Value = value;
+ PART_ProgressBar.ApplyTemplate();
+ }
+ }
+
+ internal void SetIndeterminate()
+ {
+ PART_ProgressBar.IsIndeterminate = true;
+ }
}
}
diff --git a/MahApps.Metro/Controls/Dialogs/ProgressDialogController.cs b/MahApps.Metro/Controls/Dialogs/ProgressDialogController.cs
index f42dcd5ace..0a496dd9c9 100644
--- a/MahApps.Metro/Controls/Dialogs/ProgressDialogController.cs
+++ b/MahApps.Metro/Controls/Dialogs/ProgressDialogController.cs
@@ -15,8 +15,14 @@ public class ProgressDialogController
///
/// Gets if the wrapped ProgressDialog is open.
///
+ [Obsolete("Use the Closed event instead")]
public bool IsOpen { get; private set; }
+ ///
+ /// This event is raised when the associated was closed.
+ ///
+ public event EventHandler Closed;
+
internal ProgressDialogController(ProgressDialog dialog, Func closeCallBack)
{
WrappedDialog = dialog;
@@ -24,9 +30,9 @@ internal ProgressDialogController(ProgressDialog dialog, Func closeCallBac
IsOpen = dialog.IsVisible;
- WrappedDialog.PART_NegativeButton.Dispatcher.Invoke(new Action(() => {
+ InvokeAction(() => {
WrappedDialog.PART_NegativeButton.Click += PART_NegativeButton_Click;
- }));
+ });
dialog.CancellationToken.Register(() =>
{
@@ -41,7 +47,7 @@ private void PART_NegativeButton_Click(object sender, RoutedEventArgs e)
WrappedDialog.PART_NegativeButton.IsEnabled = false;
};
- this.InvokeAction(action);
+ InvokeAction(action);
}
///
@@ -49,7 +55,7 @@ private void PART_NegativeButton_Click(object sender, RoutedEventArgs e)
///
public void SetIndeterminate()
{
- this.InvokeAction(() => WrappedDialog.PART_ProgressBar.IsIndeterminate = true);
+ InvokeAction(() => WrappedDialog.SetIndeterminate());
}
///
@@ -58,7 +64,7 @@ public void SetIndeterminate()
///
public void SetCancelable(bool value)
{
- this.InvokeAction(() => WrappedDialog.IsCancelable = value);
+ InvokeAction(() => WrappedDialog.IsCancelable = value);
}
///
@@ -68,17 +74,15 @@ public void SetCancelable(bool value)
public void SetProgress(double value)
{
Action action = () => {
- if (value < WrappedDialog.PART_ProgressBar.Minimum || value > WrappedDialog.PART_ProgressBar.Maximum)
+ if (value < WrappedDialog.Minimum || value > WrappedDialog.Maximum)
{
throw new ArgumentOutOfRangeException("value");
}
- WrappedDialog.PART_ProgressBar.IsIndeterminate = false;
- WrappedDialog.PART_ProgressBar.Value = value;
- WrappedDialog.PART_ProgressBar.ApplyTemplate();
+ WrappedDialog.ProgressValue = value;
};
- this.InvokeAction(action);
+ InvokeAction(action);
}
///
@@ -86,8 +90,8 @@ public void SetProgress(double value)
///
public double Minimum
{
- get { return this.InvokeFunc(() => WrappedDialog.PART_ProgressBar.Minimum); }
- set { this.InvokeAction(() => WrappedDialog.PART_ProgressBar.Minimum = value); }
+ get { return InvokeFunc(() => WrappedDialog.Minimum); }
+ set { InvokeAction(() => WrappedDialog.Minimum = value); }
}
///
@@ -95,8 +99,8 @@ public double Minimum
///
public double Maximum
{
- get { return this.InvokeFunc(() => WrappedDialog.PART_ProgressBar.Maximum); }
- set { this.InvokeAction(() => WrappedDialog.PART_ProgressBar.Maximum = value); }
+ get { return InvokeFunc(() => WrappedDialog.Maximum); }
+ set { InvokeAction(() => WrappedDialog.Maximum = value); }
}
///
@@ -105,7 +109,7 @@ public double Maximum
/// The message to be set.
public void SetMessage(string message)
{
- this.InvokeAction(() => WrappedDialog.Message = message);
+ InvokeAction(() => WrappedDialog.Message = message);
}
///
@@ -114,7 +118,7 @@ public void SetMessage(string message)
/// The title to be set.
public void SetTitle(string title)
{
- this.InvokeAction(() => WrappedDialog.Title = title);
+ InvokeAction(() => WrappedDialog.Title = title);
}
///
@@ -129,7 +133,7 @@ public void SetTitle(string title)
public Task CloseAsync()
{
Action action = () => {
- if (!IsOpen)
+ if (!WrappedDialog.IsVisible)
{
throw new InvalidOperationException();
}
@@ -137,10 +141,15 @@ public Task CloseAsync()
WrappedDialog.PART_NegativeButton.Click -= PART_NegativeButton_Click;
};
- this.InvokeAction(action);
+ InvokeAction(action);
- return CloseCallback().ContinueWith(x => WrappedDialog.Dispatcher.Invoke(new Action(() => {
+ return CloseCallback().ContinueWith(_ => InvokeAction(new Action(() => {
IsOpen = false;
+
+ var handler = Closed;
+ if (handler != null) {
+ handler(this, EventArgs.Empty);
+ }
})));
}
@@ -152,7 +161,7 @@ private double InvokeFunc(Func getValueFunc)
}
else
{
- return (double)this.WrappedDialog.Dispatcher.Invoke(new Func(getValueFunc));
+ return (double)WrappedDialog.Dispatcher.Invoke(new Func(getValueFunc));
}
}
@@ -164,7 +173,7 @@ private void InvokeAction(Action setValueAction)
}
else
{
- WrappedDialog.Dispatcher.Invoke(new Action(setValueAction));
+ WrappedDialog.Dispatcher.Invoke(setValueAction);
}
}
}
diff --git a/MahApps.Metro/Themes/Dialogs/ProgressDialog.xaml b/MahApps.Metro/Themes/Dialogs/ProgressDialog.xaml
index fd1f757914..475c828b46 100644
--- a/MahApps.Metro/Themes/Dialogs/ProgressDialog.xaml
+++ b/MahApps.Metro/Themes/Dialogs/ProgressDialog.xaml
@@ -39,7 +39,6 @@
Height="6"
EllipseDiameter="5"
Panel.ZIndex="5"
- IsIndeterminate="True"
Minimum="0.0"
Maximum="1.0"
Foreground="{Binding ProgressBarForeground, RelativeSource={RelativeSource AncestorType=Dialogs:ProgressDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
diff --git a/docs/release-notes/1.2.0.md b/docs/release-notes/1.2.0.md
index e70e72259b..62c934b409 100644
--- a/docs/release-notes/1.2.0.md
+++ b/docs/release-notes/1.2.0.md
@@ -77,6 +77,8 @@ This is a bug fix and feature release of MahApps.Metro v1.2.0.
+ introduce `VirtualisedMetroTreeView`
- SelectAllOnFocus for input and login dialogs #1750
- New `MetroValidationPopup` style and new `CloseOnMouseLeftButtonDown` dependency property #2058 #1469
+- Progress bar in `ProgressDialog` is not set to Indetermined by default anymore, must be set explicitly by calling `ProgressDialogController.SetIndeterminate()` #2097
+- Added `Closed` event to `ProgressDialogController` #2097
# Bugfixes
diff --git a/samples/MetroDemo/MainWindow.xaml.cs b/samples/MetroDemo/MainWindow.xaml.cs
index 27265829bd..30d990d71e 100644
--- a/samples/MetroDemo/MainWindow.xaml.cs
+++ b/samples/MetroDemo/MainWindow.xaml.cs
@@ -246,6 +246,7 @@ private async void ShowLoginDialogPasswordPreview(object sender, RoutedEventArgs
private async void ShowProgressDialog(object sender, RoutedEventArgs e)
{
var controller = await this.ShowProgressAsync("Please wait...", "We are baking some cupcakes!");
+ controller.SetIndeterminate();
await TaskEx.Delay(5000);