Новичок в WPF, изучил онлайн-учебники и у меня есть пара вопросов:
(1)Я пытаюсь, чтобы несколько кнопок разной ширины отображались рядом в одной ячейке сетки WPF. Тем не менее, они, кажется, всегда накладываются друг на друга. Что я упускаю?
(2)Можно ли контролировать абсолютную начальную левую позицию для каждой кнопки в ячейке сетки?
Спасибо.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<ScrollViewer>
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ShowGridLines ="True" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="60*" />
</Grid.ColumnDefinitions>
<Button Content="Button No. 1" Grid.Row="0" Grid.Column="0" />
<GridSplitter HorizontalAlignment="Center" Width="6"
Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" />
<Button Content="Button No. 4-2" Grid.Row="0" Grid.Column="2" Width="100" />
<Button Content="Button No. 4-1" Grid.Row="0" Grid.Column="2" Width="50" />
</Grid>
</ScrollViewer>
</Page>
Судя по ответу из Сальвадора, это работает:
<Button VerticalAlignment="Top" HorizontalAlignment="Left" Content="Button No. 1" Grid.Row="0" Grid.Column="0" Height="100"/>
<GridSplitter HorizontalAlignment="Center" Width="6"
Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" />
<Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0" Content="Button No. 4-2" Grid.Row="0" Grid.Column="2" Height="100" Width="100" />
<Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="400,0,0,0" Content="Button No. 4-1" Grid.Row="0" Grid.Column="2" Height="150" Width="50" />
Спасибо!