WPF: FindAncestor of Unknown Type

W

Wonko the Sane

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
 
N

Nicholas Paldino [.NET/C# MVP]

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?
 
W

Wonko the Sane

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 said:
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]
- (e-mail address removed)

Wonko the Sane said:
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
 
W

Walter Wang [MSFT]

Hi WtS,

I think you can use

AncestorType={x:Type UIElement}

Use AncestorLevel to skip some levels of unwanted parents.


Regards,
Walter Wang ([email protected], 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top