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:
WorkItem.WorkspacesWorkspaceNames.ModalWindows.Show(aboutDialog);
-OR-
HelpView view = WorkItem.SmartParts.AddNew<HelpView>();
WorkItem.WorkspacesWorkspaceNames.DeckWorkspace.Show(view);

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"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cab="clr-namespace:SCSFContrib.CompositeUI.WPF.Workspaces;assembly=SCSFContrib.CompositeUI.WPF">
<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>
</Menu>

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

Here is the XAML for my smart part:
<UserControl x:Class="Infrastructure.Module.Views.Help.HelpView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Background="Red" Height="200" Width="200">
<TextBlock>Hello roman, u are a coding god!</TextBlock>
</Grid>
</UserControl>
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.