tags:

views:

30

answers:

2

I have the following XAML defined.

<Popup x:Class="EMS.Controls.Dictionary.MapTip"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    PopupAnimation="Slide"
     AllowsTransparency="True" Placement="Mouse"       
       x:Name="root"                   
      >

    <Popup.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Popup.Resources>
    <Viewbox x:Name="viewBox" IsHitTestVisible="True">
        <Grid Background="Transparent" Name="mainGrid">

        </Grid>
    </Viewbox>
</Popup>

If I walk up the visual tree using VisualTreeHelper.GetParent from "mainGrid", I eventually get System.Windows.Controls.Primitives.PopupRoot, but never get the Popup itself. Anyone with a theory on why this is and what I can do about it? I neeed Popup and not PopupRoot.

TIA.

A: 

Try walking the Logical tree and not the Visual tree

LogicalTreeHelper.GetParent()
rudigrobler
A: 

Hello,

The content in a popup is added to a different visual tree with a parent which is the PopupRoot but you can use the logical tree helper to get the popup with this snippet :

LogicalTreeHelper.GetParent()

From MSDN :

When you add content to a Popup control, the Popup control becomes the logical parent to the content. Similarly, the Popup content is considered to be the logical child of the Popup. The child content is not added to the visual tree that contains the Popup control. Instead, the child content is rendered in a separate window that has its own visual tree when the IsOpen property is set to true.

++

Jmix90
Thanks for all the comments guys.
e28Makaveli