I need to create an app for TV guide. Requirement is that UI must be a copy of one you can see here: raspored.bnet.hr. As you can see, there's a lot of data. So, basically it would be a large scrollable table. Since there is no such UI control as table on Windows Phone, I found out that the best approach would be to create one vertical listbox with horizontal listboxes as its items. This is all ok and I'm able to create it. But, to make it behave like a table I also need to make these horizontal listboxes scroll in sync, not to scroll one row at a time. Then I disabled horizontal scroll on horizontal listboxes, and enabled it on the parent (vertical) listbox and while it gave the result I wanted to achieve one big problem came up - UI virtualization. I know ListBox has UI virtualization enabled by default and I can see it while scrolling on vertical listbox, but when I disable horizontal scroll on horizontal listboxes, performance is really bad, and sometimes there's an OutOfMemoryException. I understand why this happens because when I disabled horizontal scroll, those listboxes didn't know which items are on screen anymore, so the loaded all of them into memory.
What I also tried is to leave scroll on every listbox so they have UI virtualization, and then place ScrollViewer above them. Then I tried to listen on Manipulation events on scrollviewer and progamatically scroll all of the listboxes as needed. This didn't work good, first of all ManipulationDelta event doesn't appear to fire frequently enough to make scrolling smooth, and I think there could be a performance problem with calling ScrollToHorizontalOffset on ~180 listboxes.
I also tried the LongListSelector from WP8 as I read that it has much better UI virtualization and should be used instead of ListBox. The problem with this is that I couldn't make it scroll horizontally. Is it possible at all? I tried to wrap it into ScrollViewer which can scroll horizontally and it's working, but only if I set fixed width on LLS.
I also tried Telerik's RadDataBoundListBox and the problem was similar, I can't get both horizontal and vertical scrolls on the same listbox. So I could only get that each list scrolls on its own.
Can someone tell me if they had similar situation and what would be the best approach to solve this? I believe I'm not the only one that has this requirement to implement large scrollable table.
Thanks
UPDATE:
I'll just inform you that I didn't find a proper way to implement this, instead I've done it in HTML with WebBrowser control. Seems like IE already has UI virtualization implemented so it can work with large pages very well.
May be in your listbox there are images? and Out of memory Execption will occur you can do 2 things:
Don't load data in one time use BackgroundWorker
Have one local image in the App of the image you are downloading and set it as default image & when you scroll to some 50 values in forward clean the image Url to local and when it comes back give again the image url you want to show .
Because i have used it to scroll around 20k values.
Related
Windows Explorer is able to display semi-visible items when scrolling. This behaviour produces a smooth scrolling.
Is there a way to reproduce this effect with the ListView in Windows Forms?
Update
I found by change another ListView with same behaviour:
Being able to scroll by a partial line is not generally a useful feature.
However, if you really want to be able to do it, just set ShowGroups to true. The ListView control will then allow pixel level scrolling.
For example:
I've been tasked at work with creating a UserControl containing a ListView and ComboBox's for sorting the ListView data. Sorting with the Combobox's s the easy part; the part with which I'm having difficulty is implementing a method of scrolling. In the end, the control should have an Excel-like feel to it. However, sometimes the ListView is too tall or wide for where it is placed. Therefore, there two be two scrollbars somewhere on the control. One vertically moves of the ListView only, and the other moves both the ListView and ComboBox filters horizontally.
Please note in the image above that the ComboBox's do adjust themselves according to column width, but the code for that is not enabled at the moment.
What I've tried: In the control, the filter boxes are in their own panel, and the ListView has had its own panel at times. I've tried using various combinations of the HScroll/VScroll and HorizontalScroll/VerticalScroll properties and the native function ShowScrollBar() for all the controls, but nothing has worked. The only way I've gotten scrollbars to appear is by settings AutoScroll (Scrollable for the ListView) to true. Of course, the scroll bars come in pairs and work only on the same control. I also attempted to programmatically move the scroll bars, but I haven't been able to accomplish that, either.
I've got to be doing something wrong, but I'm not sure what it is. Any help is appreciated!
I think I'd go for a different solution.
If you put the ComboBoxes in a AutoSrcoll panel with the same Anchors as the ListView you would give your users the freedom to scroll the two independently.
Yes, a ScrollBar would appear and take space but I would still happily sell that as a feature, not a bug ;-)
As for handling the Scroll event of a ListView: It is hidden and you'll have to subclass it to get access to it. See here
there is a search View ( app is a MVP - PRISM WPF ) which had some issue with scrolling. it took hell of a long time to scroll when you click the scroll bar buttons. Click and dragging the scroll bar was even worse!!
considering i like anomalies, i picked it and started looking into what was going wrong. I suspected many things, but evidently the issue with the datagrid scroll was due to "ScrollViewer.CanContentScroll=True" i removed it and the scrolling was a pleasant experience compared with earlier.
Now i was wondering why my developers had put that property as true, with in couple of mins i found Doing a Page down was scrolling more than a page with out the CanContentScroll property marked true!
Now i need the scrolling to be faster AND i also need page down and page up to scroll as expected! Can some one tell me What I am missing here?? thanks!
I had similar issues with my datagrid : slow scrolling, and also randomly size changing scrollbar.
I did the following:
simplify the templates of the cells (no more nested borders and multiple colors, ToggleButtons instead of CheckBoxes)
in code use frozen colors.
this helped speed things up but did not solve the issue.
Then i set the row / cells templates height and also the RowHeight property, and then it was ok : i had both smooth scrolling and normal scrollbar. So i guess that the DataGrid was unable to compute the size of what remained to be displayed that made both the scroll slow and the scrollbar having changing size.
(Yet the rows / cells were all having same actual height in their templates since they were defined with same controls but Height property was not set...)
Hope that can help.
I just wasted my entire evening on something which I thought would be very simple but it seems WPF and Google are letting me down completely.
I need a grid, 6x6 of which I fill every row and column with a custom control. I want to be able to navigate through this grid via the keyboard (I can get those events, no problem) but I cannot seem to find how I can always have the selected grid row/column in the center of my window.
I found some carousel alike implementations, but most of them only work in a single direction and I want two way navigation, yet none seem to support this nor can I extend them to do this.
I essentially want to create a PSP alike grid navigation.
One easy way is to do this:
Create a scrollable form.
Add a 6x6 grid of child controls.
In the GotFocus (or similar) event for all the controls, set the parent form scroll offset to an appropriate position to centre the child.
This is pretty straight-forward thing to implement, with a little bit of maths to work out how to centre the x,y position of a control by setting the scroll offsets (it can be tricky/confusing, but as long as you understand the coordinate systems used for scrolling, not too bad)
Or, another approach that avoids scrolling via the windows APIs and using custom controls:
Create a form
Override OnPaint to draw your grid of 6x6 "controls" as simple graphical shapes or bitmap images centred on the selected "control".
Handle keyboard (KeyDown/Up) and mouse handling (MouseDown/Up) events to make the 36 areas of the graphic respond to user inputs in the way you desire. You'll have to track the selected item and force the window to redraw its graphics to show the new state. Enable double buffering to stop it flickering.
The first approach gives you a lot of windows-based handling for free (tabbing between controls, remembering where the input focus is, and directing events to separate classes for each "control", for example). The second approach strips away all this "help" but gives you complete control over everything, which can often help avoid unintended behaviours (e.g. it won't move the input focus when the user presses Tab unless you specifically write the code to make it do that).
I've got a Checkedlistbox, which is 3 rows high, and large enough to display about 5 elements.
As long as I've got less than 15 elements, everything runs fine.
However, if I add a sixteenth element, the checkedlistbox displays an horizontal scrollbar which takes 2 item rows, which means all the Items are now on only one row.
Worse, if I remove the extra item, the horizontal scrollbar stays in place.
I've tried using :
mycheckedlistbox.HorizontalScrollbar = false;
mycheckedlistbox.ScrollAlwaysVisible = false;
but this doesn't seem to have any effect.
I use the multicolumn=true mode, which seems to cause this misbehaviour
Is there a way to prevent the control from displaying an horizontal scrollbar, and use a vertical scrollbar instead?
I've found someone with a similar question on msdn forums, but it seems he didn't get an anwser.
Well, judging from the answers there, and from the few test I ran, this does seem sort of impossible, but at the same time, I think you're trying to defeat the purpose. If I were in you're shoes, I'd use a DataGridView with no grid lines and one that can't be editable. You have much more control over what's going on in the grid, and you can customize it MUCH more than a CheckedListBox. You can have the same effect as you can have DataGridViewCheckBoxColumns there as well.
(If you need a code sample, post in the comments, and I'll whip up a quick sample.)
The scrollbar makes the layout of the items bi-stable. You can get the scrollbar to disappear by whacking it on the head:
checkedListBox1.MultiColumn = false;
checkedListBox1.MultiColumn = true;
That forces WF to recreate the control handle, the flicker might be barely noticeable. Yes, a vertical scrollbar is possible but you'll have to give up on MultiColumn.