I want to give user ability to open multiple files and edit them using Syntax Editor control.
I have this tabbedmdihost defined in MainControl.xaml.. It has been simplified below just to give idea.
<docking:TabbedMdiHost x:Name="tabbedMdiHost">
<docking:TabbedMdiContainer>
<docking:DocumentWindow Title="WelcomeDocument.rtf" Description="Rich-text document" FileName="C:\Users\Actipro\My Documents\x.rtf">
<editor:SyntaxEditor x:Name="editor"
AreWordWrapGlyphsVisible="True"
IsLineNumberMarginVisible="True"
ZoomLevel="{Binding ElementName=scaleSlider, Path=Value}"
DocumentChanged="OnSyntaxEditorDocumentChanged"
DocumentIsModifiedChanged="OnSyntaxEditorDocumentIsModifiedChanged"
DocumentParseDataChanged="OnSyntaxEditorDocumentParseDataChanged"
IsOverwriteModeActiveChanged="OnSyntaxEditorIsOverwriteModeActiveChanged"
UserInterfaceUpdate="OnSyntaxEditorUserInterfaceUpdate"
ViewSelectionChanged="OnSyntaxEditorViewSelectionChanged"
ViewSplitAdded="OnSyntaxEditorViewSplitAdded"
ViewSplitMoved="OnSyntaxEditorViewSplitMoved"
ViewSplitRemoved="OnSyntaxEditorViewSplitRemoved"
Width="1870"
Height="880"
MinWidth="700"
MinHeight="500"
MaxWidth="1870"
MaxHeight="900"
WordWrapMode="None">
<editor:EditorDocument xml:space="preserve" FileName="Document1.txt" />
</editor:SyntaxEditor>
</docking:DocumentWindow>
</docking:TabbedMdiContainer>
</docking:TabbedMdiHost>
In my MainControl.xaml.cs I have :
private static void OnNewExecuted(object sender, ExecutedRoutedEventArgs e)
{
MainControl control = (MainControl)sender;
control.CreateSyntaxEditorDocumentWindow();
}
private DocumentWindow CreateSyntaxEditorDocumentWindow()
{
string filename = "newachfile.ach";
editor.Document.SetText(String.Empty);
DocumentWindow documentWindow = new DocumentWindow(dockSite, null, System.IO.Path.GetFileName(filename),
new BitmapImage(new Uri("/Resources/Images/TextDocument16.png", UriKind.Relative)), editor);
documentWindow.Description = "New Ach File";
documentWindow.FileName = filename;
documentWindow.Activate();
return documentWindow;
}
When I open new file, it shows up and use the syntax editor object defined in MainControl.xaml, but then when I switch to one of the previously entered files on the tabs, nothing happens with documentWindow. It seems that I have to create a new syntax editor object for each document window. But how do I set that up dynamically with all the frills that were in MainControl.xaml?