Module/Workspace initialization sequence problem

Mar 27, 2008 at 11:25 AM
Hello,
i am having a little problem adding a WPF-UserControl, implemented in a custom module, to the TabWorkspace. I am loading the module by the profileCatalog.xml
That works but the Module is loaded before the Workspace in the WindowMain.xaml is registered so i cannot add the Usercontrol from the module to the tabWorkspace. Can someone tell me, if i can change the sequence of ínitialization?

I try to add the usercontrol in the the 'TestModul' -> TestWorkItem class in method OnRunStarted():

protected override void OnRunStarted()
{
base.OnRunStarted();
IWorkspace GPSWorkspace = RootWorkItem.Workspaces"testws";
// GPSWorkspace.Show( Items.AddNew<UserControl1>());
}
The uncommented loc doesn t work because the workspace is not initilize by that moment.

My ProfileCatalog.xml looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >
<Modules>
<ModuleInfo AssemblyFile="TestModul.dll"/>
</Modules>
</SolutionProfile>


By the way i used the WPFCAB sample project 'TabWorkSpace' for my demo.

Thanks for any help...







Mar 27, 2008 at 1:50 PM
Ok, I solved the problem :)
At least i hope so. The Error was that i created the MainWindow after too late. No my application is loaded the following way. Maybe someone can tell me, if that is the right way?

App.xaml:

public partial class App : SCSFContrib.CompositeUI.WPF.IInitializeApplication
{}

Shell.cs:


public sealed class Shell : SCSFContrib.CompositeUI.WPF.ApplicationShellApplication<RootWorkItem, App>
{
STAThread
public static void Main()
{
new Shell().Run();
}


protected override void AfterShellCreated()
{
base.AfterShellCreated();
CreateMainShellWindow();
}

private void CreateMainShellWindow()
{
MainWindow shellWindow = new MainWindow();
Shell.MainWindow = shellWindow;
shellWindow.Show();
RootWorkItem.Workspaces.Add(shellWindow.tabWorkspace, "tabWorkspace");
}
}

MainWindow.xaml

Just created the TabWorkspace in xaml

RootWorkItem.cs


public sealed class RootWorkItem : WorkItem
{
protected override void OnRunStarted()
{
base.OnRunStarted();
}
}

I don t really need the class or? As long as i doesn t extend the methods i can take the Base workItem, right?

Thanks for help