I have a XAML GridView showing a lot of items, scrolling vertically. At the bottom I'd like to have some whitespace below the last row but still inside the ScrollViewer.
What's the best way to achieve this? Should this be applied to the ItemsWrapGrid? If so, can anyone give me an example how to do that?
You can just add a padding in your GridView:
<GridView Name="myGridView" Padding="0,0,0,180"/>
Related
I am not experienced in Windows Store (aka Metro) app XAML, so perhaps I am overlooking something simple, but according to books and samples, a vertical scrollbar is a natural part of a ListView control, and unless explicitly disabled will show up when there are invisible items in the ListView.
But on in the case of my app. I have a typical List/Detail page with items in the left pane - they are displayed fine, with scrollbar, and selected item details in the right pane. Selected item contains a collection of subitems, and they are supposed to be displayed with a scrollbar in case there are many of them. I have a simple ListView definition:
<ListView
x:Name="itemCollection"
Grid.ColumnSpan="1"
SelectionChanged="ItemListView_SelectionChanged"
ItemsSource="{Binding Elements}"
ItemTemplate="{StaticResource Custom80ItemTemplate}" />
Strange enough, I never see a scrollbar for this list. Only when I explicitly set its mode to "Visible", I can see a scroll bar, but there is nothing to scroll it with!
Obviously the program believes that the whole list is visible so scroll bar is unnecessary, but what can make it do such judgement?
I've finally fixed the problem. As most of such problems, the error was silly: a Grid control that owns this ListView had an extra (wrong) row definition that had Height property marked with asterisk, i.e. taking all remaining space. But the row that ListView was using had Height marked as "Auto", therefore it expanded to the whole size of its items and never activated its vertical scroll bar.
Try Setting the visibility to auto.
Good afternoon.
I'm having a problem resizing a listview in a form.
In the normal position the listview is placed correctly as you can see in the image.
When i maximize the form, i get a huge space between the top controls and the listview.
How can i solve this situation, so the listview can expand and stay near the other controls?
Thank you.
Set the ListView's Anchor property to all four sides.
I'd like to get the effect visible on the picture:
I don't think it is. A GridView already has a ScrollViewer in itself, so multiple of them does not make sense. I would try to use a single GridView with GroupStyleSelector/ItemContainerStyleSelector/ItemTemplateSelector implementations and DataTemplates to define each item. A less dynamic version might just be a ScrollViewer with Style set to HorizontalScrollViewerStyle, a horizontal StackPanel and a few VariableSizedWrapGrids - if you bind the GridView to some groups or other panels to define the content.
This looks like a good sample based on the description (though the images seem to be missing for me).
I've got a WrapPanel which will contain several different custom UserControls. Depending on the scenario, I may need to filter down which UserControls are visible. My goal is that I can switch which controls are visible on the fly by showing/hiding the controls that need to be filtered - thus shifting the controls that are left showing, to the top-left of the panel.
Right now I am simply setting the Visibility property of the control to Visibility.Collapsed when I don't want them to appear. I thought that because I was using a WrapPanel, the rest of the controls would shift to the top-left of the panel.
Instead, after hiding some of the UserControls, the controls that are still visible stay exactly where they were before, and I am left with gaps between the controls that are still showing. I've opened my app in Silverlight Spy, and it shows that the UserControls are still actually there (which makes sense) but are simply invisible.
So my question is:
Is there a way that I can show/hide UserControls within a WrapPanel which allows the still-visible UserControls to slide to their new positions (all shifting towards the top left - similar to a StackPanel)?
I've debated removing the UserControls completely from the WrapPanel (I think this would work) and storing them in memory until they are needed. Then if I wanted to show/hide other controls, I would get them from my in-memory object. It seems like there should be a better way to do this though.
If anyone has any suggestions or advice, it would be greatly appreciated. Thanks!
-Lloyd
UPDATE:
XAML: (very simple)
<toolkit:WrapPanel x:Name="MyLayout" Height="300" HorizontalAlignment="Left" VerticalAlignment="Top" Width="400" />
Code-Behind: The UserControls are getting added dynamically:
MyLayout.Children.Add(oUserControl)
And they are getting set to collapsed dynamically as well:
oUserControl.Visibility = Visibility.Collapsed
I think I've found the problem. We added the WrapPanel to a ScrollViewer recently, and when I took the ScrollViewer out I was able to achieve the functionality I wanted.
I'm not sure why the ScrollViewer would have that effect though?
Also, I've found that I can leave the ScrollViewer in place and simply call .Measure() on the WrapPanel to update the layout.
Neither option makes 100% sense to me, but they do both seem to work.
I have one gridview which was in a panel and I set panel's Scrollbars property as vertical and height 200px. Gridview has number of rows (say 1000). If i scroll down and selected a 900th row,scroll bar will move to top.I want to focus on that row after selection(ie.scroll bar will be on the same position when we selected). Is there anyone to help me?
your gridview can have scrollbars too I think.
Otherwise try using datagridview. they are slightly different with properties.
If that doesnt work check the properties of your gridview.
Are you allowed to edit or select anything?
I think if you answer those questions the solution will show itself.
Hope this helped.