我制作了一个动态GridView,它从DataBase中获取一些信息。GridView中的多高度单元格 - XAML
每GridViewCell是由一个又一个网格,这样每个单元都有不同数量的行内的...
我的问题是,如果我有一个小区有很多行的表格看起来奇怪...
这是我想了如何创建我的GridView控件:
┌─────┬────┬────┐
│ │ │ │
│ ├────┤ │
├─────┤ │ │
│ │ ├────┤
│ ├────┤ │
└─────┴────┴────┘
我希望有人能帮助我:d
编辑
这里是我的代码:
网格:
<Grid>
<GridView
x:Name="listaSpecifiche" SelectionMode="None"
IsSwipeEnabled="false" Height="Auto"
IsItemClickEnabled="False" ItemsSource="{Binding Source={StaticResource sorgenteListaSpecifiche}}"
IsHitTestVisible="False" ItemTemplate="{StaticResource specificaTemplate}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource gruppoSpecificaTemplate}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,20,0" Visibility="Visible"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="0,-9,0,0" />
<Setter Property="BorderBrush" Value="Blue" />
<Setter Property="BorderThickness" Value="1" />
</Style>
</GridView.ItemContainerStyle>
</GridView>
</Grid>
的DataTemplate:
<DataTemplate x:Key="specificaTemplate">
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="350" />
</Grid.ColumnDefinitions>
<TextBlock Margin="7,0,0,0" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="14" Text="{Binding Descrizione}"/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" Text="{Binding Valore}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="gruppoSpecificaTemplate">
<Grid Margin="5,0,0,5">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="650"/>
</Grid.ColumnDefinitions>
<StackPanel Background="#BB000795" Height="30" Grid.Row="0">
<TextBlock Text="{Binding Key}" Style="{StaticResource GroupHeaderTextStyle}" HorizontalAlignment="Left"
VerticalAlignment="Top" FontSize="16" FontWeight="Bold" Foreground="White" Margin="7,-10,0,0" />
</StackPanel>
</Grid>
</DataTemplate>
编辑
我tryed更改组的创建的GridView,现在我没有使用分组的GridView和它只是GridView控件的ListView控件,问题仍然存在,我认为这是因为
<WrapGrid Orientation='Vertical' />
我tryed使用的StackPanel或VirtualisingStackPanel现在还出现了只有一列(使现在很多网格已经超过了边距)。
有没有办法在StackPanel有一些溢出时创建1个或多个列?
什么是 “werid” 是什么意思?你能告诉我们你当前的代码和它做了什么吗? – almulo
看起来您正在使用错误的控件进行工作。也许你需要一组StackPanels或其他东西 –
我已经添加了我的代码,我使用的是GridView,因为我需要使用GroupStyle从一个源创建不同的表格 –