error with WPF SmartParts and ISmartPartInfoProvider

Topics: CAB & Smart Client Software Factory
Jul 18, 2007 at 10:28 PM
Edited Jul 18, 2007 at 10:31 PM
I noticed today while creating my first wpf smartpart that it wasn't utilizing the GetSmartPartInfo method that was created when I implemented the ISmartPartInfoProvider interface. So I tracked the problem down to this snippet in CompositeUI.WPF.Workspaces.ElementHostWorkspace.Show(object smartPart) method:

object originalSmartPart = smartPart;
if (smartPart is UIElement)
smartPart = elementHosts.Wrap(smartPart as UIElement);

. . .

ISmartPartInfoProvider provider = smartPart as ISmartPartInfoProvider;

If you look at the underlined code, you see that smartpart has been assigned the WPF wrapper. Now unless the wrapper always implements ISmartPartInfoProvider (I don't think it does, period), then the variable 'provider' will always be null (because smartpart is now of type ElementHost). The correct code should be:

ISmartPartInfoProvider provider = originalSmartPart as ISmartPartInfoProvider;
Jul 19, 2007 at 2:22 PM
Hi, you just found an issue. I’m going to create a WorkItem for this.

The way you proposed to solve it looks right.


Ezequiel Jadib
Jul 19, 2007 at 2:22 PM
Edited Jul 19, 2007 at 2:24 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

Ezequiel Jadib