bovender framework
C# framework that implements MVVM and more
MessageContent.cs
1 /* MessageContent.cs
2  * part of Daniel's XL Toolbox NG
3  *
4  * Copyright 2014-2018 Daniel Kraus
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
19 
20 namespace Bovender.Mvvm.Messaging
21 {
27  {
28  #region Public properties
29 
30  public string Caption { get; set; }
31 
32  public string Message { get; set; }
33 
34  public string OkButtonText { get; set; }
35 
36  public string CancelButtonText { get; set; }
37 
38  public bool Confirmed { get; set; }
39 
40  #endregion
41 
42  #region Commands
43 
48  public DelegatingCommand ConfirmCommand
49  {
50  get
51  {
52  if (_confirmCommand == null)
53  {
54  _confirmCommand = new DelegatingCommand(
55  (param) => { DoConfirm(); },
56  (param) => { return CanConfirm(); }
57  );
58  };
59  return _confirmCommand;
60  }
61  }
62 
63  #endregion
64 
65  #region Constructors
66 
70  public MessageContent() : base() { }
71 
72  #endregion
73 
74  #region Protected methods
75 
81  protected virtual void DoConfirm()
82  {
83  Confirmed = true;
84  DoCloseView();
85  }
86 
91  protected virtual bool CanConfirm()
92  {
93  return true;
94  }
95 
96  #endregion
97 
98  #region Private properties
99 
100  private DelegatingCommand _confirmCommand;
101 
102  #endregion
103 
104  public override object RevealModelObject()
105  {
106  return null;
107  }
108  }
109 }
Command that implements ICommand and accepts delegates that contain the command implementation.
virtual bool CanConfirm()
Determines whether the ConfirmCommand can be executed.
Conveys a message from a view model to a consumer (typically, a view) that has subscribed to the Sent...
Definition: Message.cs:31
MessageContent()
Creates a new, empty message content.
virtual void DoConfirm()
Executes the confirmation logic: sets Confirmed to True and calls DoCloseView() to issue a RequestClo...
override object RevealModelObject()
Returns the model object that this view model wraps or null if there is no wrapped model object...
Simple object that encapsulates a boolean value; to be used in MVVM interaction with MessageArgs...