A DataFormField contains an EditingContentControl which is used for editing the value. The editing control has 2 properties which support opening a dialog window to edit the value: DialogWindowType and IsDialogWindowOpen. When IsDialogWindowOpen is set to true, if there is a DialogWindowType specified, then a new instance of the window will be created and it will be opened with the Window.ShowDialog method. By default, the content of the editing control is set as the dialog window’s content, and if the dialog window closes with OK, then the editor’s content is set to the dialog window’s content, which presumably has been changed. That’s the basics.

The easy way to use a dialog window is to define a DataFormFieldDescriptor for your field and set its EditorSettings with an instance of DialogWindowEditorSettings. DialogWindowEditorSettings has several properties which allow you to fine tune the behavior to your needs. One such property is DialogWindowType, which by default is the DialogWindow control that is part of DotNetBar.

Now I am guessing that you might want to use FileOpenDialog to let the user pick a file, then store the file path in a property of the data object being edited. But FileOpenDialog is not a Window, so it can’t be opened directly by the editing control. What you can do to get around this is define a custom window that can be opened by the editing control and that itself opens the open file dialog. By making the window transparent the user won’t know it’s there. For example:

public class OpenFileDialogLauncherWindow : Window
public OpenFileDialogLauncherWindow()    
         WindowStyle = WindowStyle.None;
         AllowsTransparency = true;
         Loaded += delegate
             Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, (Action)OpenFileDialog);
     private void OpenFileDialog()
         var dialog = new OpenFileDialog();
         if ((DialogResult = dialog.ShowDialog(this)).GetValueOrDefault())
             Content = dialog.FileName;
     } }


Let’s say the property that will store the file path is named TemplatePath. Here’s how you could use OpenFileDialogLauncherWindow in Xaml:

<dc:DataFormFieldDescriptor PropertyName="TemplatePath" DisplayName="Template Path">
                              DialogWindowType="{x:Type local:OpenFileDialogLauncherWindow}" />
         </dc:DataFormFieldDescriptor.EditorSettings> </dc:DataFormFieldDescriptor