IUIPlugin attaching to SMF ControllerContainer

Mar 31, 2011 at 10:03 AM


Is here a way to get a UIPlugin attached to the SMF ControllerContainer (any container) and determine where it placed in til ControllerContainer (container)?

I can get the UIPlugin to attach to the root of the players visual tree, but not to the ControllerContainer.

- araft


Sep 7, 2011 at 4:44 PM

From the Plugin Developer Guide:

Target – This is a string that indicates the location, within the Visual Tree, where the UI Element should be added. This string must match the name of some Panel within the player’s existing UI. SMF will use this value to locate the correct Panel and then add the UI Element to its children. If the value of Target is null or empty the UI Element will be added to PlayerRoot.

But, I haven't managed to get it working. I've tried "functioncontrols", which is where I'd like to see it attached and "ControllerContainer" but both gave me my custom UI element floating in the middle of the player.

Any help would be appreciated ;)

Sep 9, 2011 at 8:54 AM

I'm trying to debug this, something's strange:

I'm setting Target to return 'functioncontrols', which is the Grid containing CC, version, volume, etc... at the bottom right.

OnUIPluginLoaded which I've copied from SMF sources:

Panel targetControl = !uiPlugin.Target.IsNullOrWhiteSpace()
                                ? this.GetVisualChild<Panel>(uiPlugin.Target)
                                : PlayerRoot;

Step in, targetControl.Name => VideoAreaElement

This is totally unrelated! functioncontrols is inside ControllerContainer, VideoAreaElement is an 'older brother' of ControllerContainer.


I found the bug! A copy/paste error apparently.

public static TChild GetVisualChild<TChild>(this DependencyObject parent, string name) where TChild : FrameworkElement
            TChild visualChild = null;
            int children = VisualTreeHelper.GetChildrenCount(parent);

            for (int i = 0; visualChild == null && i < children; i++)
                DependencyObject target = VisualTreeHelper.GetChild(parent, i);
                if (target is TChild && ((FrameworkElement)target).Name == name)
                    visualChild = target as TChild;
                    visualChild = GetVisualChild<TChild>(target);

            return visualChild;
The recursive call in red calls the wrong method! It should be: GetVisualChild<TChild>(target, name)! I'm opening an issue with the fix.

Sep 9, 2011 at 9:00 AM
Edited Sep 9, 2011 at 9:01 AM

Work item: http://smf.codeplex.com/workitem/21470

Sep 10, 2011 at 12:13 AM

Thanks for reporting this! I've made this change to the source and it will be available in the next release.