Tôi đang cố gắng để có được một TextBox để điền vào không gian có sẵn trong một cột có thể thay đổi kích thước. TextBox là một phần của một điều khiển người dùng:Làm thế nào để có được một TextBox để điền vào một cột có thể thay đổi kích thước?
<UserControl x:Class="TextBoxLayout.FieldControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Name</Label>
<TextBox Grid.Column="1"/>
</Grid>
</UserControl>
điều khiển người dùng này là trong một cửa sổ với một splitter dọc:
<Window x:Class="TextBoxLayout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TextBoxLayout"
Title="Text box layout" Height="400" Width="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<local:FieldControl Grid.Column="0" Grid.Row="0" MaxWidth="200" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Testing"/>
<GridSplitter Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="3"/>
<TextBlock Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Text="Testing"/>
</Grid>
</Window>
Vấn đề là hộp văn bản dường như là rất hẹp - Những gì tôi muốn muốn nó làm là điền vào cột bên trái và thay đổi kích thước với splitter. Làm thế nào để làm điều đó?
Bạn có nghĩa là vừa với chiều rộng hoặc cả chiều rộng và chiều cao? – Alex
Vừa với chiều rộng. – imekon