【发布时间】:2013-05-08 10:45:46
【问题描述】:
我有一个固定宽度的StackPanel。在StackPanel 里面我有一个GridView,Width 应该被限制在它的父宽度(smth like Width="*")。
我的示例 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′S GRIDVIEW – NOT MEANT FOR DATA ENTRY!
-
我的示例中的TextBoxes仅用作示例项目,实际上我仅在该GridView中呈现数据
标签: c# wpf xaml windows-8 windows-runtime