This project is read-only.

SmartPartPlaceholder Not shown

Jun 16, 2010 at 3:10 AM

I am learning the Contrib now and have problem with SmartPartPlaceholder.

The simple xaml is like this


         ...definitions ...

          <cab:SmartPartPlaceholder  SmartPartShown="LeftPlaceHolder_SmartPartShown"  SmartPartName="StudyPanelLeftViewInstance"/>

           <GridSplitter Grid.Column="1" ResizeDirection="Columns" Width="5" VerticalAlignment="Stretch"   Background="blue"  />

           ...simple other things like lables




Then I add the smartpart in modulecontroller.AddViews() generated by SCSF template

_studyPanelLeftView = WorkItem.Items.AddNew<StudyPanelLeftView>("StudyPanelLeftViewInstance");


After that, I add button to toolbar. After click the toolbar, the view is shown on shell 

_studyPanelView = ShowViewInWorkspace<StudyPanel>(SmartService.Infrastructure.Interface.Constants.WorkItemNames.RootViewOfStudyModule, Constants.WorkspaceNames.LayoutWorkspace);


The labels of study panel shown on the shell correctly while the _studyPanelLeftView now shown.

I can debug into the handler LeftPlaceHolder_SmartPartShown, that means the SmartPart has been loaded. But why I can not see it? I checked the visibility property of the smartpart, is is visible. 

I have dig into the problem for several days, and I do not know where to begin for this problem. Is anybody encounter similar issue before? And can you give me some suggestion for this. It just now shown in the workspace, and maybe easy for you.

Thanks a lot for any help from you.





Jun 17, 2010 at 4:34 PM

I have debug into the codes and buildup function works to create the target SmartPart.  But the screen for placeholder display nothing and other controls/views display well.

Now I run the BankTellerWpf.sin (vs2008) in sample folder of SmartClientContrib-Release1.5-src, in which the UserInfo view is placed in placeholder.The view does not displayed as well.

So I guess this might be one environment issue. But do not know where is it?

Has anybody encounter this issue and would you like to share something? Thanks a lot.


Oct 18, 2010 at 1:20 PM
Edited Oct 18, 2010 at 1:20 PM

I've solved this problem by changing the following method in SmartPartPlaceHolder.cs :

		/// Raises the  event.
		protected virtual void OnSmartPartShown(SmartPartPlaceHolderEventArgs e)
			Guard.ArgumentNotNull(e, "e");

		    this.Content = e.SmartPart;  //this is the missing action
			EventHandler handler = SmartPartShown;

			if (handler != null)
				handler(this, e);

... and also modifying the Builder Strategy 'FrameworkElementSmartPartStrategy.cs' : move the call to PopulateIfPlaceholder() from BuildUp() to AddHierarchy():


		private void AddHierarchy(WorkItem workItem, FrameworkElement frameworkElement)
            PopulateIfPlaceholder(workItem, frameworkElement);

            foreach (object child in LogicalTreeHelper.GetChildren(frameworkElement))
				if (!AddToWorkItem(workItem, child))
					FrameworkElement childFrameworkElement = child as FrameworkElement;

					if (childFrameworkElement != null)
						AddHierarchy(workItem, childFrameworkElement);