35 #region Public (dependency) properties 39 get {
return (
string)GetValue(CaptionProperty); }
42 SetValue(CaptionProperty, value);
48 get {
return (
string)GetValue(MessageProperty); }
51 SetValue(MessageProperty, value);
57 get {
return (
string)GetValue(Param1Property); }
60 SetValue(Param1Property, value);
66 get {
return (
string)GetValue(Param2Property); }
69 SetValue(Param2Property, value);
75 get {
return (
string)GetValue(Param3Property); }
78 SetValue(Param3Property, value);
82 public string OkButtonText
84 get {
return (
string)GetValue(OkButtonTextProperty); }
87 SetValue(OkButtonTextProperty, value);
91 public string CancelButtonText
93 get {
return (
string)GetValue(CancelButtonTextProperty); }
96 SetValue(CancelButtonTextProperty, value);
104 public string FormattedText
110 if (_formattedText == null)
112 _formattedText = String.Format(
Message, Param1, Param2, Param3);
114 Logger.Info(_formattedText);
115 return _formattedText;
119 Logger.Warn(
"Cannot format notification message: no Message");
120 return "*** No message text given! ***";
127 #region Declarations of dependency properties 129 public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
132 public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
135 public static readonly DependencyProperty Param1Property = DependencyProperty.Register(
138 public static readonly DependencyProperty Param2Property = DependencyProperty.Register(
141 public static readonly DependencyProperty Param3Property = DependencyProperty.Register(
144 public static readonly DependencyProperty OkButtonTextProperty = DependencyProperty.Register(
147 public static readonly DependencyProperty CancelButtonTextProperty = DependencyProperty.Register(
168 :
this(caption, message)
170 OkButtonText = okButtonText;
173 public NotificationAction(
string caption,
string message,
string okButtonText,
string param)
174 :
this(caption, message, okButtonText)
179 public NotificationAction(
string caption,
string message,
string okButtonText,
string param1,
string param2)
180 :
this(caption, message, okButtonText, param1)
185 public NotificationAction(
string caption,
string message,
string okButtonText,
string param1,
string param2,
string param3)
186 :
this(caption, message, okButtonText, param1, param2)
193 #region Implementation of abstract base methods 206 if (!String.IsNullOrEmpty(Caption))
208 Logger.Info(
"GetDataContext: Overriding caption");
209 messageContent.Caption = Caption;
211 if (!String.IsNullOrEmpty(
Message))
213 Logger.Info(
"GetDataContext: Overriding message");
214 messageContent.Message = FormattedText;
216 if (!String.IsNullOrEmpty(OkButtonText))
218 Logger.Info(
"GetDataContext: Overriding OK button text");
219 messageContent.OkButtonText = OkButtonText;
221 if (!String.IsNullOrEmpty(CancelButtonText))
223 Logger.Info(
"GetDataContext: Overriding OK button text");
224 messageContent.CancelButtonText = CancelButtonText;
226 return messageContent;
231 #region Private fields 233 private string _formattedText;
239 private static NLog.Logger Logger {
get {
return _logger.Value; } }
241 private static readonly Lazy<
NLog.Logger> _logger =
new Lazy<
NLog.Logger>(() =>
NLog.LogManager.GetCurrentClassLogger());
override ViewModels.ViewModelBase GetDataContext(MessageContent messageContent)
Gets a ViewModelBase object that will be injected into the view In the abstract base class...
Conveys a message from a view model to a consumer (typically, a view) that has subscribed to the Sent...
Abstract base class for MVVM messaging actions.
Interaction logic for NotificationView.xaml
override Window CreateView()
Returns a view that can bind to expected message contents.
Simple object that encapsulates a boolean value; to be used in MVVM interaction with MessageArgs...
Opens a generic WPF dialog window that displays a message and has a single OK button.