Revit .NET has provided the DockablePane API since version 2014. In this series of posts, we are going to explore the Revit DockablePane .NET API step by step.
In the first part, we created the simplest custom DockablePane to get the basic idea first about the DockablePane API. After that, we enhanced the custom DockablePane a bit and docked it to the ElementView window and created some code to show the custom DockablePane back in case it has been hidden. We also added a button to the custom DockablePane which will call the Revit Save command to save the current Revit model when being clicked. We also listed out the information about both the custom DockablePane itself and WPF Page it hosted.
Since we have worked around the issue of not being able to directly access to the hosted WPF Page, it seems we can reset the custom DockablePane programmatically. Let’s give it a try.
Add one more button to the Page1.xaml:
<Button Content="Make DockablePane Float" Height="23" HorizontalAlignment="Left" Margin="12,50,0,0" Name="button3" VerticalAlignment="Top" Width="276" Click="button3_Click" />
Implement its callback as follows.
private void button3_Click(object sender, RoutedEventArgs e)
DockablePane pane = ExtApp._cachedUiCtrApp.GetDockablePane(ExtApp.paneId);
if (pane != null)
DockablePaneProviderData data = ExtApp.CachedPaneData[ExtApp.paneId];
data.InitialState.DockPosition = DockPosition.Floating;
data.InitialState.FloatingRectangle.Left = 400;
data.InitialState.FloatingRectangle.Top = 400;
data.InitialState.FloatingRectangle.Right = 800;
data.InitialState.FloatingRectangle.Bottom = 800;
data.FrameworkElement.Width = 200;
Now we are expecting to see that the custom DockablePane will be made float and its size (FloatingRectangle) or at least its width should be changed. However, here is the result.
Though the hosted WPF Page by the custom DockablePane has been changed successfully in the width, the custom DockablePane itself just ignores our request of making it float and changing its window size even if the Hide() and Show() pair have been tried to refresh the custom DockablePane.
The InitialState property of the DockablePaneProviderData object may indicate something; only the initial state of the custom DockablePane can be set through the DockablePaneProviderData object. After the DockablePaneProviderData object being registered and shown, the status such as docking or float, position, and tab behind of the custom DockablePane cannot be dynamically changed anymore.
Revit Addin Wizard (RevitAddinWizard) provides various wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.