I'm looking for a control that can hold a list of text items.
For example:
Item 1
Item 2
Item 3
When I add a new item to this list (Item 4 for example), I want the new item to appear at the bottom of the list, and the other items to shift up 1 position. So in this example, adding Item 4, will mean that Item 1 will disappear from the list.
The reason I have not just gone with a listview is because I want the items to scroll up, like an animated transition if that makes sense?
Is there something out there that can do this, or should I be writing my own control?
EDIT: An example of a web based control:
http://buildinternet.s3.amazonaws.com/projects/totem/index.html
EDIT 2: I'm also not after a horizontal marquee control.
You can do that with a ListBox. It isn't exactly a beautiful solution, but adding to its collection and then either scrolling or setting the selected index to ListBox.Items.Count - 1 works.
[Edit:] Oh right, animated. I believe the scrolling is animated if you set the selected index, but I doubt it will be satisfying if you are going for nice graphics.
Related
I ran into kind of a dilemma with WPF's scrolling behavior in a ListBox:
When I set ScrollViewer.VerticalScrollBarVisibility="Auto" inside the ListBox, scrolling works fine. But clicking on the last half-visible element will move the item up to bring it into view, and the items then are aligned to the top of the topmost item, not the bottom of the lowest one. This is especially annoying when double clicking, as the item will move up under the cursor, and the second click will potentially hit the next element, thus opening the wrong one.
Alternatively, I could put the whole ListBox inside a ScrollViewer. This way, when clicking on the last visible item, the items are nicely aligned to the bottom of this element. But this breaks scrolling using the mouse wheel, and PageDown jumps to the last item instead of one page down.
Is there a way to have ListBox scrolling just work correctly?
To the point one:
Did you try to set ScrollViewer.CanContentScroll="False"?
I have two problems with a ListView I am using.
My ListView is set as ListViewView.View = List and I am adding a few items to it, via ListView.Items.Add(string).
The first one, I notice that for text items that are wider than the width of the ListView itself there is no horizontal scroll bad, and I can't seem to find a way to enable it.
The second is that to select an item I need to select click on part of the item itself, rather than the line the item is in. In other words, if I have an item with a really small length, I can't click anywhere on the line to select it, I have to click on it.
Here is an the code I have an what I am seeing:
listView1.Items.Add("aaaabbbbccccddddffffeeeegggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz");
listView1.Items.Add("a");
As you can see from the image above there are no scroll bars and the length of the text on Index[0] is much wider than the width of the ListView
Likewise on Index[1] where the text is just a single a, to select it I have to click directly on top of the a rather than anywhere else in the line.
Is there a way of fixing these two problems easily?
Also the reason why I'm using a ListView is because I want to add images to the items.
Thanks.
For your second problem just set the FullRowSelect to true in properties or you can do listview1.FullRowSelect = true;
I am wondering if it is possible to change the Background Color of a series of items in a comboBox. I wish to have the colors for various items change when viewing the list a whole (clicking the little down arrow).
Basically the desired process would go like this:
1) Open form
2) Click on comboBox (list drops down to display all items)
3) "Unavailable" items are then shown with a red Background color, while the available ones remain the default color (in this case white).
Note that no items have been selected yet, only the item list has been shown
Please let me know if it is even possible to achieve something this specific with the ComboBox control.
I am making a WP7 app which has a Listbox of UserControls. Each UserControl has an ItemsControl and Button(for getting more results). On click of the button the ItemsControl items will be increased by 5 or 10.
Now on clicking on the GetMore button of any of the usercontrols except the first or last, there will be an increase in Scrollable height(Total height of the listbox) of the ListBox but the VerticalOffset(position of scrollbar from top) of the ListBox remains same. Now the problem I am facing is that the Vertical Offset is not absolute but relative to Scrollable Height. So the content being viewed till then will be changed basing on the new value of ScollableHeight.
I want to know the relation between them, so that I can do some math and set the VerticalOffset value.
I have added some dependency properties on VerticalOffset and ScrollableHeight through which I can get the events when any of them is changed. Trying to use ScrollIntoView for readjusting the Vertical Offset
Any suggestions or corrections are highly appreciated.
I am not able to find the calculation. But what can be done is listbox can be replaced by a scrollviewer which has itemsControl inside it. But the disadvantage of this is virtualisation is disabled, so will need to check on this.
But, overall this is going to give a bad experience on using such a UserControl in Listbox. So using templated list box given in WP7 toolkit is an option but it is gonna hang a bit since ListBox is not optimized for multi templated virtualization. So I started showing writing listbox item template in such a way it contains all the possible layouts which will enabled from a condition.
My problem is that I have a databinded ItemsControl with some data presented in a list and user can scroll up and down.
When adding new items to the list (i.e. user refreshes the list), the scroll position moves according to however many new items there are. Is there a way to keep the scroll position upon adding new items?
Thanks
If you have a look at the TombStone Helper project on Codeplex in the ListBoxTombstoner.cs class [1] you will find code which allows you to get at the underlying ScrollViewer for the listbox and get its VerticalOffset property.
You will then be able to manipulate this property however you want - either adding to it if you want the scroll position to move as you add items, or keep it the same.
[1] http://tombstonehelper.codeplex.com/SourceControl/changeset/view/e737b2a34421#TombstoneHelper%2fListBoxTombstoner.cs
Try to set IsSynchronizedWithCurrentItem="True" on the ListBox
Assuming that all items are of a fixed height you should be able to adjust the the ScrollOffset after the addition-being sure to take the number of added items into consideration.