I have a normal GridView, that displays grouped data. My goal is to move the header (a button) from the top of the group to the left of the group.
<GridView>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid>
<Button Content="{Binding Title}"/>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid ItemWidth="240" ItemHeight="160" Orientation="Vertical" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
<GridView.ItemTemplate>
<!-- item template -->
</GridView.ItemTemplate>
</GridView>
An answer to this question Grouping GridView in Windows 8 Metro App - while not completely the same desired layout - says that the desired layout is not possible without adding an extra "dummy tile".
I'm wondering if it is possible to achieve my goal - to move the header from the top of the group to the left of the group - without such an extra "dummy tile".
Write a Css for GridView header position. 2. Add the Css in GridView's HeaderStyle tag. 3. Set column header width.
This does not seem to work if you have things like "AllowSorting" set to true or if you have added other postback functionality to the header. If you have sorting enabled for instance, and you click on the header column to sort, the entire gridview disappears. You can try overflow css property.
The 3-rd ASP.NET GridView controls (such as the ASPxGridView from DevExpress component vendor provide this functionality. None of these solutions works as expected. All of them rely on fixed-width columns and either separate header from rest of the table or use IE-specific top:expression (...) which does not work on any other browser. btw.
GridView can be scrolled vertically. GridView doesn't have the ability to scroll. But if the GridView contains a larger number of rows or columns (say more than 100 rows and 15 columns), we want it to have scrollbars.
You need to edit the header container style. In Visual Studio, right-click the GridView and select
Edit Group Style -> Edit Generated Item Container (Container Style) -> Edit a Copy
You will see the Group Header, which is a Content Control, and the Group Items, which are an ItemsControl. Both are contained inside a grid that, in the default, is simple two rows. You can add a column, move the Group Header into Grid.Column=0
& Grid.Row=1
and you should be good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With