diff --git a/Samples/Stylet.Samples.HelloDialog/Dialog1View.xaml b/Samples/Stylet.Samples.HelloDialog/Dialog1View.xaml
index 9f6b139..713f4d2 100644
--- a/Samples/Stylet.Samples.HelloDialog/Dialog1View.xaml
+++ b/Samples/Stylet.Samples.HelloDialog/Dialog1View.xaml
@@ -1,8 +1,17 @@
-
+ xmlns:s="http://github.com/canton7/Stylet"
+ Title="Dialog1View" Height="145" Width="300">
+
+
+
+
+
-
+
+
+
+
+
diff --git a/Samples/Stylet.Samples.HelloDialog/Dialog1ViewModel.cs b/Samples/Stylet.Samples.HelloDialog/Dialog1ViewModel.cs
index fc0783f..85d412b 100644
--- a/Samples/Stylet.Samples.HelloDialog/Dialog1ViewModel.cs
+++ b/Samples/Stylet.Samples.HelloDialog/Dialog1ViewModel.cs
@@ -8,9 +8,16 @@ namespace Stylet.Samples.HelloDialog
{
public class Dialog1ViewModel : Screen
{
+ public string Name { get; set; }
+
public Dialog1ViewModel()
{
this.DisplayName = "I'm Dialog 1";
}
+
+ public void Close()
+ {
+ this.TryClose(true);
+ }
}
}
diff --git a/Samples/Stylet.Samples.HelloDialog/ShellView.xaml b/Samples/Stylet.Samples.HelloDialog/ShellView.xaml
index b7ac1ef..8adad9f 100644
--- a/Samples/Stylet.Samples.HelloDialog/ShellView.xaml
+++ b/Samples/Stylet.Samples.HelloDialog/ShellView.xaml
@@ -3,7 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://github.com/canton7/Stylet"
Title="ShellView" Height="300" Width="300">
-
-
-
+
+
+
+
+
+
+
diff --git a/Samples/Stylet.Samples.HelloDialog/ShellViewModel.cs b/Samples/Stylet.Samples.HelloDialog/ShellViewModel.cs
index e06961a..a5ba9e2 100644
--- a/Samples/Stylet.Samples.HelloDialog/ShellViewModel.cs
+++ b/Samples/Stylet.Samples.HelloDialog/ShellViewModel.cs
@@ -11,18 +11,30 @@ namespace Stylet.Samples.HelloDialog
private IWindowManager windowManager;
private IDialogFactory dialogFactory;
+ private string _nameString;
+ public string NameString
+ {
+ get { return this._nameString; }
+ set { SetAndNotify(ref _nameString, value); }
+ }
+
public ShellViewModel(IWindowManager windowManager, IDialogFactory dialogFactory)
{
this.DisplayName = "Hello Dialog";
this.windowManager = windowManager;
this.dialogFactory = dialogFactory;
+
+ this.NameString = "Click the button to show the dialog";
}
public void ShowDialog()
{
var dialogVm = this.dialogFactory.CreateDialog1();
- this.windowManager.ShowDialog(dialogVm);
+ if (this.windowManager.ShowDialog(dialogVm).GetValueOrDefault())
+ this.NameString = String.Format("Your name is {0}", dialogVm.Name);
+ else
+ this.NameString = "Dialog cancelled";
}
}
diff --git a/Stylet/PropertyChangedBase.cs b/Stylet/PropertyChangedBase.cs
index 72a5ddd..c9d3424 100644
--- a/Stylet/PropertyChangedBase.cs
+++ b/Stylet/PropertyChangedBase.cs
@@ -39,5 +39,14 @@ namespace Stylet
}
});
}
+
+ protected virtual void SetAndNotify(ref T field, T value, [CallerMemberName] string propertyName = "")
+ {
+ if (Comparer.Default.Compare(field, value) != 0)
+ {
+ field = value;
+ this.NotifyOfPropertyChange(propertyName);
+ }
+ }
}
}