WPF Follow Parent’s Size 1


There are different ways to get child size follows parent’s size, here I collect 3 of them first:

1: Using ElementName:

<…. Parent container > (note: StackPanel not work maybe? not sure here)  
<TextBox Width="{Binding ElementName=ParentContainer, Path=ActualWidth}"
    Text="Text" HorizontalAlignment="Left" MaxWidth="200" />
</…. Parent container >

2: Using DataTemplate:

Width="{Binding ActualWidth,RelativeSource={RelativeSource FindAncestor, 
AncestorType={x:Type ScrollContentPresenter}}}"

3: Use Grid:

        <ColumnDefinition Width="*" MaxWidth="100"/>

    <TextBox Text="Text" />

Anyway, you have to know different case get different result, not guarantee above methods work for your case.