- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have spent few days trying to figure out how to dock simple WPF pane, went through all available tutorials yet something is not working and I cannot call InitializeComponent(); when initializing my WPF Page.
First of all I found out that there are two ways to register dockable pane.
- UIControlledApplication.RegisterDockablePane
- UIApplication.RegisterDockablePane
Is there a difference?
The example at UIControlledApplication.RegisterDockablePane shows this:
public Result OnStartup(UIControlledApplication application)
{
// Create our pane provider and register it with the application
PaneProvider prov = new PaneProvider();
DockablePaneId id = new DockablePaneId(Guid.NewGuid());
application.RegisterDockablePane(id, "test", prov);
return Result.Succeeded;
}
But if I create ViewPane (PaneProvider) like this:
public partial class ViewPane : Page, IDisposable, IDockablePaneProvider
{
public ViewPane()
{
Debug.WriteLine("[ViewPane]");
try
{
Debug.WriteLine("[ViewPane][InitializeComponent]");
InitializeComponent();
}
catch (Exception ex)
{
TaskDialog.Show("[ViewPane] Error", ex.Message);
}
}
I get error:
Could not load file or assembly 'AutomateWallCreation, Version=0.0.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
The pane is registered but black.
If I go the other way, with UIApplication.RegisterDockablePane:
and use ApplicationInitialized event like this:
public Result OnStartup(UIControlledApplication UIpplication)
{
UIpplication.ControlledApplication.ApplicationInitialized += RegisterViewPane;
return Result.Succeeded;
}
private void RegisterViewPane(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
{
Debug.WriteLine("[RegisterViewPane]");
var registerPaneCommand = new RegisterDockablePaneManager();
registerPaneCommand.Execute(new UIApplication(sender as Autodesk.Revit.ApplicationServices.Application));
}
///
///differenct class
///
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
internal class RegisterDockablePaneManager : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
return Execute(commandData.Application);
}
public Result Execute(UIApplication application)
{
Debug.WriteLine("[RegisterDockablePaneManager]");
var data = new DockablePaneProviderData();
var pane = new ViewPane();
DTO.viewPane = pane;
data.FrameworkElement = pane as FrameworkElement;
var dpid = new DockablePaneId(DockablePaneIdentifierManager.GetViewPaneGuid());
application.RegisterDockablePane(dpid, "ViewPane", DTO.viewPane as IDockablePaneProvider);
return Result.Succeeded;
}
}
I get same error:
Could not load file or assembly 'AutomateWallCreation, Version=0.0.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
The pane is registered but black.
What could be the reason for failure to InitializeComponent(); at startup ?
Solved! Go to Solution.