260eeec1855227efc3a4206920023d5d3036543f
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / PropertyEditing / DialogPropertyValueEditor.cs
1 namespace System.Activities.Presentation.PropertyEditing {
2     using System;
3     using System.Collections.Generic;
4     using System.Text;
5     using System.Windows;
6
7     using System.Runtime;
8
9     /// <summary>
10     /// Container for any and all dialog-editing logic for PropertyEntries.  This class can hold
11     /// either a DataTemplate for a dialog editor or custom logic that will be called when
12     /// the dialog is invoked.
13     /// </summary>
14     public class DialogPropertyValueEditor : PropertyValueEditor {
15
16         private DataTemplate _dialogEditorTemplate;
17
18         /// <summary>
19         /// Creates a DialogPropertyValueEditor
20         /// </summary>
21         public DialogPropertyValueEditor()
22             : this(null, null) { }
23
24         /// <summary>
25         /// Creates a DialogPropertyValueEditor
26         /// </summary>
27         /// <param name="dialogEditorTemplate">A DataTemplate that is hosted in a host specific dialog chrome
28         /// and has its DataContext set to the PropertyValue that corresponds to the property being edited.</param>
29         /// <param name="inlineEditorTemplate">A DataTemplate that is used for the inline editor UI.  If used,
30         /// its DataContext will be set to the PropertyValue that corresponds to the property being edited.</param>
31         public DialogPropertyValueEditor(DataTemplate dialogEditorTemplate, DataTemplate inlineEditorTemplate) 
32             : base(inlineEditorTemplate) {
33             _dialogEditorTemplate = dialogEditorTemplate;
34         }
35
36         /// <summary>
37         /// Gets or sets the DataTemplate that is hosted by a host specific dialog and has its DataContext set to
38         /// a PropertyValue.  If this property returns null, ShowDialog() will be called instead.
39         /// </summary>
40         [Fx.Tag.KnownXamlExternalAttribute]
41         public DataTemplate DialogEditorTemplate
42         {
43             get { return _dialogEditorTemplate; }
44             set { _dialogEditorTemplate = value; }
45         }
46
47         /// <summary>
48         /// This method is called when the DialogEditorTemplate is null and a dialog has been invoked by the user.
49         /// Overriding this method allows you to implement any custom dialog logic, such invoking existing
50         /// system dialogs.
51         /// </summary>
52         /// <param name="propertyValue">The PropertyValue for the property being edited</param>
53         /// <param name="commandSource">The IInputElement that can be used as a source for execution of
54         /// PropertyValueEditorCommands.  Since these commands get handled by the host and since custom
55         /// dialogs are not going to be part of that visual tree, the commandSource exposes an IInputElement
56         /// that is part of the host's visual tree and which, therefore, may be used to execute property
57         /// editing commands in such a way that they will be handled correctly.</param>
58         public virtual void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) {
59         }
60
61         internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode) {
62             return base.GetPropertyValueEditor(mode) ??
63                 (mode == PropertyContainerEditMode.Dialog ? _dialogEditorTemplate : (DataTemplate)null);
64         }
65     }
66 }