469,602 Members | 1,931 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

WPF: FindAncestor of Unknown Type

Hello,

I am creating a ControlTemplate for a ComboBox. This ComboBox will have a
transparent background so it uses the control it is placed in as its
background.

I would like the background of the Popup to also match the parent control.
It cannot use the Transparent background of the ComboBox, because it may span
outside the parent control. However, we want there to be enough flexibility
to place this on different controls, so I don't necessarily know the parent
control type to use FindAncestor against.

Thanks,
WdS
Jan 17 '08 #1
3 4639
WdS,

So why are you calling FindAncestor? If you want the popup background
to be transparent, then just specify it in the declaration of the popup (or
not, if you don't want that). Why the call to FindAncestor?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wonko the Sane" <Wonko the Sa**@nospam.nospamwrote in message
news:4B**********************************@microsof t.com...
Hello,

I am creating a ControlTemplate for a ComboBox. This ComboBox will have a
transparent background so it uses the control it is placed in as its
background.

I would like the background of the Popup to also match the parent control.
It cannot use the Transparent background of the ComboBox, because it may
span
outside the parent control. However, we want there to be enough
flexibility
to place this on different controls, so I don't necessarily know the
parent
control type to use FindAncestor against.

Thanks,
WdS
Jan 17 '08 #2
Sorry - I wrote that after a very long day....

The problem is that the popup is transparent. I actually want the popup
background to be the color of the parent of the combobox.

Thanks,
WtS

"Nicholas Paldino [.NET/C# MVP]" wrote:
WdS,

So why are you calling FindAncestor? If you want the popup background
to be transparent, then just specify it in the declaration of the popup (or
not, if you don't want that). Why the call to FindAncestor?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wonko the Sane" <Wonko the Sa**@nospam.nospamwrote in message
news:4B**********************************@microsof t.com...
Hello,

I am creating a ControlTemplate for a ComboBox. This ComboBox will have a
transparent background so it uses the control it is placed in as its
background.

I would like the background of the Popup to also match the parent control.
It cannot use the Transparent background of the ComboBox, because it may
span
outside the parent control. However, we want there to be enough
flexibility
to place this on different controls, so I don't necessarily know the
parent
control type to use FindAncestor against.

Thanks,
WdS
Jan 17 '08 #3
Hi WtS,

I think you can use

AncestorType={x:Type UIElement}

Use AncestorLevel to skip some levels of unwanted parents.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 19 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ronald S. Cook | last post: by
3 posts views Thread by Linda Liu[MSFT] | last post: by
7 posts views Thread by Jeremy | last post: by
23 posts views Thread by raylopez99 | last post: by
reply views Thread by Andy | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.