Live Chat Icon For mobile
Live Chat Icon

How do I make the UserControl B FILL the UserControl A it’s hosted in?

Platform: WPF| Category: Custom Controls

You can bind B’s Width and Height to that of A’s. For example, in the XAML where you define B:

<local:B Width='{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type A}}, Path=Width}' /local:B>

If there is an ActualWidth property in A, then you might want to bind B’s Width to that instead. Do the same for Height.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.