新的WPF多個控件,並通過輔導性學習的網上,並有幾個問題:有一個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" />
謝謝!
完美,工作只是我想要的方式: – Shawn 2012-04-12 21:32:58