开发者

WPF: how to get remaining width in a StackPanel?

开发者 https://www.devze.com 2022-12-25 09:54 出处:网络
Given the code below: <Window x:Class=\"Window3\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"

Given the code below:

<Window x:Class="Window3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window3" Height="300" Width="300">
    <StackPanel Background="Yellow" Orientation="Horizontal">
        <TextBlock Background="Green" Text="some text" Width="200"/>
        <TextBox Width="{Binding ???}" />
        <TextBlock Background="Red" Text="some text" Width="50"/>
    </StackPanel>
</Window>

how do you bind second textbox's width as to fill the remaining space?

Please keep in mind I'm lo开发者_Go百科oking for a binding solution: I know how to do it using other layouts (like DockPanel or grid) but I'm not interested in that. Also, using ElementName is not of interest.

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号