Skip to content

Commit 5b0f6ad

Browse files
committed
expose IsEnded on DialogSession #125
1 parent 1e1cc19 commit 5b0f6ad

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
208208
{
209209
dialogHost._asyncShowWaitHandle.Set();
210210
dialogHost._attachedDialogClosingEventHandler = null;
211-
dialogHost._session.IsDisabled = true;
211+
dialogHost._session.IsEnded = true;
212212
dialogHost._session = null;
213213
return;
214214
}
@@ -403,7 +403,7 @@ internal void Close(object parameter)
403403
{
404404
var dialogClosingEventArgs = new DialogClosingEventArgs(_session, parameter, DialogClosingEvent);
405405

406-
_session.IsDisabled = true;
406+
_session.IsEnded = true;
407407

408408
//multiple ways of calling back that the dialog is closing:
409409
// * routed event
@@ -418,7 +418,7 @@ internal void Close(object parameter)
418418
if (!dialogClosingEventArgs.IsCancelled)
419419
SetCurrentValue(IsOpenProperty, false);
420420
else
421-
_session.IsDisabled = false;
421+
_session.IsEnded = false;
422422

423423
_closeDialogExecutionParameter = parameter;
424424
}

MaterialDesignThemes.Wpf/DialogSession.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace MaterialDesignThemes.Wpf
77
/// </summary>
88
public class DialogSession
99
{
10-
private readonly DialogHost _owner;
11-
internal bool IsDisabled;
10+
private readonly DialogHost _owner;
1211

1312
internal DialogSession(DialogHost owner)
1413
{
@@ -17,6 +16,14 @@ internal DialogSession(DialogHost owner)
1716
_owner = owner;
1817
}
1918

19+
/// <summary>
20+
/// Indicates if the dialog session has ended. Once ended no further method calls will be permitted.
21+
/// </summary>
22+
/// <remarks>
23+
/// Client code cannot set this directly, this is internally managed. To end the dicalog session use <see cref="Close()"/>.
24+
/// </remarks>
25+
public bool IsEnded { get; internal set; }
26+
2027
/// <summary>
2128
/// Gets the <see cref="DialogHost.DialogContent"/> which is currently displayed, so this could be a view model or a UI element.
2229
/// </summary>
@@ -40,7 +47,7 @@ public void UpdateContent(object content)
4047
/// <exception cref="InvalidOperationException">Thrown if the dialog session has ended, or a close operation is currently in progress.</exception>
4148
public void Close()
4249
{
43-
if (IsDisabled) throw new InvalidOperationException("Dialog session has ended.");
50+
if (IsEnded) throw new InvalidOperationException("Dialog session has ended.");
4451

4552
_owner.Close(null);
4653
}
@@ -52,7 +59,7 @@ public void Close()
5259
/// <exception cref="InvalidOperationException">Thrown if the dialog session has ended, or a close operation is currently in progress.</exception>
5360
public void Close(object parameter)
5461
{
55-
if (IsDisabled) throw new InvalidOperationException("Dialog session has ended.");
62+
if (IsEnded) throw new InvalidOperationException("Dialog session has ended.");
5663

5764
_owner.Close(parameter);
5865
}

0 commit comments

Comments
 (0)