我有一個固定寬度的StackPanel
。在StackPanel
裏面,我有一個GridView
,其中Width
應該被限制在它的父寬度(像寬度=「*」一樣)。從父級繼承的GridView寬度
我的樣品XAML:
<StackPanel Orientation="Horizontal" Width="300" Height="300">
<TextBox Width="50" Margin="0" Height="50" Background="Blue"></TextBox>
<GridView >
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" FlowDirection="LeftToRight" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.Items>
<TextBox Width="50" Margin="0" Height="50" Background="Green"></TextBox>
<TextBox Width="50" Margin="0" Height="50" Background="Green"></TextBox>
<TextBox Width="50" Margin="0" Height="50" Background="Green"></TextBox>
<TextBox Width="50" Margin="0" Height="50" Background="Green"></TextBox>
<TextBox Width="50" Margin="0" Height="50" Background="Green"></TextBox>
</GridView.Items>
</GridView>
</StackPanel>
在這個例子中GridView
寬度比母體更寬,所以它的一些項的不顯示(未包裹的)。當我將GridView
寬度設置爲固定值時,項目被打包,但我無法在我的項目中使用固定值。
爲什麼在GridView中使用TextBox?請參閱[WINDOWS 8的GRIDVIEW - 不是爲數據輸入!](http://netitude.bc3tech.net/2013/04/12/windows-8s-gridviewnot-meant-for-data-entry/) – Xyroid 2013-05-08 11:34:42
TextBoxes在我的例子中只用作示例項目,實際上我只在該GridView中提供數據 – filip 2013-05-08 11:38:17