Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Created November 12, 2009 17:36
Show Gist options
  • Select an option

  • Save panesofglass/233098 to your computer and use it in GitHub Desktop.

Select an option

Save panesofglass/233098 to your computer and use it in GitHub Desktop.
A presentation model (view model) interface for WPF and Silverlight
using System;
using System.ComponentModel;
using System.Windows.Input;
using Foundation.Client.Views;
namespace Foundation.Client.PresentationModels
{
/// <summary>
/// Common interface for all presentation layer models.
/// </summary>
public interface IPresentationModel : IHeaderInfoProvider<string>, INotifyPropertyChanged
{
#region properties
/// <summary>
/// Gets the broken rules.
/// </summary>
/// <value>The broken rules.</value>
BrokenRuleCollection BrokenRules { get; set; }
/// <summary>
/// Gets a value indicating whether this instance can close.
/// </summary>
/// <value><c>true</c> if this instance can close; otherwise, <c>false</c>.</value>
bool CanClose { get; }
/// <summary>
/// Gets or sets a value indicating whether this instance can submit changes.
/// </summary>
/// <value><c>true</c> if this instance can submit changes; otherwise, <c>false</c>.</value>
bool CanSubmitChanges { get; set; }
/// <summary>
/// Gets the close view command.
/// </summary>
/// <value>The close view command.</value>
ICommand CloseViewCommand { get; }
/// <summary>
/// Gets or sets a value indicating whether to hide buttons when inside a wizard.
/// </summary>
/// <value><c>true</c> if buttons should be hidden; otherwise, <c>false</c>.</value>
bool HideButtons { get; set; }
/// <summary>
/// Gets a value indicating whether this instance is dirty.
/// </summary>
/// <value><c>true</c> if this instance is dirty; otherwise, <c>false</c>.</value>
bool IsDirty { get; }
/// <summary>
/// Gets a value indicating whether this instance is editable.
/// </summary>
/// <value>
/// <c>true</c> if this instance is editable; otherwise, <c>false</c>.
/// </value>
bool IsEditable { get; set; }
/// <summary>
/// Gets or sets the key used to identify active views.
/// </summary>
/// <value>The key.</value>
string Key { get; set; }
/// <summary>
/// Gets the show view command.
/// </summary>
/// <value>The show view command.</value>
ICommand ShowViewCommand { get; }
/// <summary>
/// Gets or sets the view.
/// </summary>
/// <value>The view.</value>
IView View { get; set; }
#endregion
#region events
/// <summary>
/// Occurs when the presentation model is closed.
/// </summary>
event EventHandler<EventArgs> Closed;
#endregion
#region methods
/// <summary>
/// Closes the view.
/// </summary>
void CloseView();
/// <summary>
/// Refreshes this instance.
/// </summary>
void Refresh();
/// <summary>
/// Shows the view inside the specified <paramref name="region" />.
/// </summary>
/// <param name="region">The region.</param>
void ShowView(IRegion region);
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment