wpfsilverlightpixelsenseitemtemplatescatterview

ActivationHost for ElementMenu


I am creating dynamically ScatterView items using a template:

<s:ScatterView.ItemTemplate >
    <DataTemplate>
        <DockPanel LastChildFill="True" >
            <DockPanel.Background>
                <ImageBrush ImageSource="{Binding Type, Converter={StaticResource imgSelector}}"
                            Stretch="Fill" />
            </DockPanel.Background>
            <TextBox Background="Transparent" DockPanel.Dock="Top" Text="{Binding Path=Message}"
                     IsReadOnly="True" TextWrapping="Wrap" />
            <s:ElementMenu Name="emBallMenu" VerticalAlignment="Top"
                           ActivationMode="HostInteraction" ActivationHost="?????">
                <s:ElementMenuItem Header="Send back" x:Name="emiSendBack"
                                   Command="local:MainSurfaceWindow.MenuItemCommand"
                                   CommandParameter="{Binding Path=BallId}"/>
            </s:ElementMenu>
        </DockPanel>
    </DataTemplate>
</s:ScatterView.ItemTemplate>

What should I set in the ActivationHost of the emBallMenu so that menu gets activated on a finger tap on the parent ScatterView.ItemTemplate?


Solution

  • The correct response is :

    <s:ElementMenu Name="emBallMenu" 
        VerticalAlignment="Top" 
        ActivationMode="HostInteraction" 
        ActivationHost="{Binding RelativeSource=RelativeSource FindAncestor, 
                        AncestorType={x:Type s:ScatterViewItem}}}" 
    />
    

    I found this in here