This project is read-only.

Smart Part Not Displayed in Workspace

Aug 31, 2007 at 4:27 PM
Where should I look to determine why content from a smart part isnt being displayed in a workspace?

I have 2 workspaces. A DeckWorkspace and a WindowWorkspace. Both of these workspaces appear to be properly initialized.

When I call the following code:
HelpView view = WorkItem.SmartParts.AddNew<HelpView>();

Neither workspace shows the content of the HelpView.

Here is the XAML for my Shell (this is hosting the deck workspace)
<Window x:Class="ChopperScab.Infrastructure.Shell.MainWindow"
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top">
<MenuItem Header="File" x:Name="fileMenuItem"></MenuItem>
<MenuItem Header="OnlineStore" x:Name="onlineStoreMenuItem"></MenuItem>
<MenuItem Header="Help" x:Name="helpMenuItem"></MenuItem>

<StatusBar DockPanel.Dock="Bottom" x:Name="_mainStatusBar" Height="24">
<StatusBarItem x:Name="_leftStatusBarItem"></StatusBarItem>
<StatusBarItem x:Name="_centerStatusBarItem"></StatusBarItem>
<StatusBarItem x:Name="_rightStatusBarItem"></StatusBarItem>
<TextBlock>Test 123</TextBlock>
<cab:DeckWorkspace x:Name="_DeckWorkspace"/>
<TextBlock>Test 456</TextBlock>

Here is the XAML for my smart part:
<UserControl x:Class="Infrastructure.Module.Views.Help.HelpView"
<Grid Background="Red" Height="200" Width="200">
<TextBlock>Hello roman, u are a coding god!</TextBlock>
Aug 31, 2007 at 6:23 PM
It turns out that the project that contained my user control did not have the <Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" /> xml element applied in the CSPROJ file. By not having the xml element my code would not copile with the InitializeComponent attribute in the user control. After adding the xml element to the CSPROJ file, the user controls would compile with the call to InitializeComponent in place.

So, long story short, in order for the user controls to be displayed in the workspace the user control needs to have the call to InitializeComponent. If the code will not compile with InitializeComponent in place, chance are the <Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" /> element is missing from the CSPROJ.