Autosizing controls in XAML to fit a stack panel / dock panel, where the middle control is what needs to fill the space

StackOverflow https://stackoverflow.com/questions/17813441

Question

How can I create this...

command http://img841.imageshack.us/img841/2631/46lc.jpg

in WPF.

I've read alot of other questions on using stack panel vs dock panel but can't seem to recreate what I want. This is what I currently have..

command2 http://img13.imageshack.us/img13/5374/7oft.jpg

and my xaml..

<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="DarkGray" Grid.ColumnSpan="2" Grid.Row="1" LastChildFill="False" >
            <TextBlock Text="{StaticResource commandText}" Style="{StaticResource Heading2}" Margin="0,0,0,0" VerticalAlignment="Center" DockPanel.Dock="Left" />
            <TextBox Name="inputTextBox" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
            <Button x:Name="termSend" Content="{StaticResource sendText}" Margin="0,0,0,8" DockPanel.Dock="Right" VerticalAlignment="Center" />
        </DockPanel>
Was it helpful?

Solution

<DockPanel>
   <TextBlock VerticalAlignment="Center" Text="Command" DockPanel.Dock="Left"/>
   <Button Content="Send" VerticalAlignment="Center" DockPanel.Dock="Right"/>
   <TextBox VerticalAlignment="Center" Margin="5"/>
</DockPanel>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top