Revit 2017 - Simple Dockable Pane using C# - Blank page?

Revit 2017 - Simple Dockable Pane using C# - Blank page?

mileta_pejovic
Enthusiast Enthusiast
2,931 Views
2 Replies
Message 1 of 3

Revit 2017 - Simple Dockable Pane using C# - Blank page?

mileta_pejovic
Enthusiast
Enthusiast

Thanks on all great posts on the forum which helped me to start entering into Revit API world 🙂

At the very beginning I have a problem with Dockable panel created for revit 2017.
The problem is shown in the attached picture (blank/black dockable panel space even though I created page.xaml)

What do I do wrong?
Here's the code for App:

namespace DockTest
{
class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication a)
{
//TODO: Register dockable panel "Test".
Test page1 = new Test();
DockablePaneId paneId = new DockablePaneId(new Guid("9d7ed357-534f-4d87-afc4-8e784e3b119e"));
a.RegisterDockablePane(paneId, "Test", (IDockablePaneProvider)page1);

return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication a)
{
return Result.Succeeded;
}
}
}

 

and this is the code for .xaml:

<Page x:Class="DockTest.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DockTest"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="Test">

<Grid Background="#FFE1E1E1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>

</Grid.ColumnDefinitions>
<Label Grid.Row="0">Log</Label>
<StackPanel Grid.Row="0">
<Button Name="checkAllButton" Click="checkAllButton_Click">Check All</Button>
<Button Name="checkNoneButton" Click="checkNoneButton_Click">Check None</Button>
<Button Name="okButton" Click="okButton_Click">OK</Button>
<Button Name="cancelButton" Click="cancelButton_Click">Cancel</Button>
<Button Name="isolateButton" Click="isolateButton_Click">Isolate</Button>
</StackPanel>

<TextBox Name="tb_output" Grid.Row="1" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" TextChanged="tb_output_TextChanged"/>
<Label Content="Project Name:" Grid.Row="2" Height="28" HorizontalAlignment="Left" Name="lblProjectNameHeading" VerticalAlignment="Top" Margin="-1,6,0,0" />
<Label Content="Label" Grid.Row="2" Height="26" HorizontalAlignment="Left" Margin="76,6,0,0" Name="lblProjectName" VerticalAlignment="Top" Width="114" />
</Grid>

</Page>

code for xaml.cs:

namespace DockTest
{
/// <summary>
/// Interaction logic for Test.xaml
/// </summary>
public partial class Test : Page, IDockablePaneProvider
{
public void SetupDockablePane(DockablePaneProviderData data)
{
data.FrameworkElement = this as FrameworkElement; ;

data.InitialState.DockPosition = DockPosition.Tabbed;
//data.InitialState.TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.PropertiesPalette;
data.InitialState.TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.ElementView;
}

private void checkAllButton_Click(object sender, RoutedEventArgs e)
{

}

private void checkNoneButton_Click(object sender, RoutedEventArgs e)
{

}

private void okButton_Click(object sender, RoutedEventArgs e)
{

}

private void cancelButton_Click(object sender, RoutedEventArgs e)
{

}

private void isolateButton_Click(object sender, RoutedEventArgs e)
{

}

private void tb_output_TextChanged(object sender, TextChangedEventArgs e)
{

}
}
}
Thanks in advance,
Mileta

0 Likes
Accepted solutions (1)
2,932 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Hi Mileta,

 

The page is displaying as blank because you've not initialised the components in your class file.  You can fix it by adding a call to InitializeComponent();

 

For example:

 

public partial class Test : Page, IDockablePaneProvider
{
        // Initialize Components
public Test() { InitializeComponent(); } public void SetupDockablePane(DockablePaneProviderData data) { ... }

Hopefully this should get you up and running.

 

 

Cheers,

Adam

Message 3 of 3

mileta_pejovic
Enthusiast
Enthusiast

Thanks a lot, all is working now
As I said, just starting with Revit API and C# and all posts on the forum are more than helpful.

 

0 Likes