how to bind width of child element to width of parent element in silverlight

后端 未结 6 1278
南笙
南笙 2021-01-30 20:15

I have a grid whose width is \"1*\". So the actual width decided at runtime I think. Within that grid I have another grid whose width I want to set to the runtime width of paren

6条回答
  •  盖世英雄少女心
    2021-01-30 20:38

    This is generic solution which may work everywhere. You wouldn't need to write parent element name. This will identify its parent and will take parent's width.

    Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
    

提交回复
热议问题