|
using System;
using System.Windows.Input;
namespace FsRichTextBoxDemo
{
public class LoadDocumentCommand : ICommand
{
#region Fields
// Member variables
private MainWindowViewModel m_ViewModel;
#endregion
#region Constructor
/// <summary>
/// Default constructor.
/// </summary>
public LoadDocumentCommand(MainWindowViewModel viewModel)
{
m_ViewModel = viewModel;
}
#endregion
#region ICommand Members
/// <summary>
/// Whether the LoadDocumentCommand is enabled.
/// </summary>
public bool CanExecute(object parameter)
{
return true;
}
/// <summary>
/// Actions to take when CanExecute() changes.
/// </summary>
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
/// <summary>
/// Executes the LoadDocumentCommand
/// </summary>
public void Execute(object parameter)
{
/* We set the Document property on the view model to simulate
* a document load from the app back-end. */
m_ViewModel.DocumentXaml = "<FlowDocument PagePadding=\"5,0,5,0\" AllowDrop=\"True\" "
+ "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">"
+ "<Paragraph>Text generated by app back-end</Paragraph></FlowDocument>";
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.