Unable to cast object of type 'MS.Internal.NamedObject' to type TreeItemViewModel
<p>I am getting an exception randomly while i do my copy action using context menu 
"Unable to cast object of type 'MS.Internal.NamedObject' to type TreeItemViewModel"</p>

<p>Here is the code of my context menu </p>

<pre><code>&lt;ContextMenu x:Key="MyContextMenu" &gt;
        &lt;ContextMenu.Resources&gt;
            &lt;obj:BindingProxy x:Key="vmProxy" Data="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget, Converter={StaticResource FindNamedElementFromSourceTreeConverter}, ConverterParameter=MyTreeView}"/&gt;
            &lt;obj:BindingProxy x:Key="modelProxy" Data="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext}"/&gt;
        &lt;/ContextMenu.Resources&gt;

 &lt;MenuItem Header="{core:Localization Key=Copy}" 
                  CommandParameter="{Binding Source={StaticResource modelProxy}, Path=Data}"
                  Command="{Binding Source={StaticResource vmProxy}, Path=Data.DataContext.CopyCommand}"&gt;
        &lt;/MenuItem&gt;
 &lt;/ContextMenu&gt;
</code></pre>

<p>This context menu is used in My tree view item style as below</p>

<pre><code>&lt;Style x:Key="MyTreeViewItemStyle" TargetType="TreeViewItem"&gt;

        &lt;Style.Triggers&gt;
            &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataContext, Converter={StaticResource TypeOfConverter}}" Value="{x:Type models:MyModel1}"&gt;                
                &lt;Setter Property="ContextMenu" Value="{StaticResource MyContextMenu}"/&gt;
            &lt;/DataTrigger&gt;
        &lt;/Style.Triggers&gt;
    &lt;/Style&gt;
</code></pre>

<p>This Style is added to the Treeview as below</p>

<pre><code>&lt;TreeView x:Name="MyTreeView"
                          DockPanel.Dock="Top"
                          Padding="0"
                          ItemsSource="{Binding MyTreeItems}"
                          BorderThickness="0"                         
                          ItemContainerStyle="{StaticResource MyTreeViewItemStyle}"/&gt;
</code></pre>

<p>Here is my Converter</p>

<pre><code> public class FindNamedElementFromSourceTreeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string name = parameter as string;
            if (string.IsNullOrEmpty(name)) return null;


            DependencyObject dp = value as DependencyObject;
            if (dp == null) return null;

            DependencyObject root = DependencyObjectHelper.FindRootElement(dp);
            if (root == null) return null;

            DependencyObject result = DependencyObjectHelper.FindChild(root, name);
            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
</code></pre>

<p>The "Unable to cast object of type" exception happens when excecute copycommand through the context menu item on right click of the treeviewItem. the same copy command is been used by another button in the UI which is working fine with out any issues. Please let me know how to solve this issue .. </p>