WPF: Change padding depending of container ?

Posted by Alex Ilyin on Stack Overflow See other posts from Stack Overflow or by Alex Ilyin
Published on 2010-04-12T11:01:41Z Indexed on 2010/04/12 11:03 UTC
Read the original article Hit count: 201

Filed under:
|

I have UserControl named MyUserControl, and another UserControl named MyContainer. I want MyUserControl to have padding 10 if it is placed inside MyContainer and 15 otherwise. Shortly, I want

<MyContainer>
  <MyUserControl>
   Hello
  </MyUserControl>
</MyContainer>

to look like

<MyContainer>
  <UserControl Padding="10">
   Hello
  </UserControl>
<MyContainer>

and

<MyUserControl>
 Hello
</MyUserControl>

to look like

<UserControl Padding="15">
  Hello
</UserControl>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about styles