Windows Phone : Long List Multi Selector - Adding items in SelectedItems List manually from code. Checkbox not checked - windows-phone-7

I am having a Long List Multi Selector with Grouping enabled to have jump list feeling for Windows Phone 8 app.
We can select maximum of 8 items in long list multi selector. After selecting the items the items can be seen checked and in code as well I am able to retrieve them via SelectedItems list.
But when I am trying to come back to that page again with same item source to Long List MultiSelector and trying to get Selected Items list pre-selected when Long List Multi Selector is opened the functionality is not happening.
PFB the sample code for the same:-
foreach (var item in SelectedValue)
MultiSelectLongList.SelectedItems.Add(item);
everything else is working correctly in Long List multi selector except for preselecting some items when list is opened.
Is there any other way of doing it. Please help me out.
Thanks

If you are using the Phone toolkit LongListMultiSelector control, this should actually just work.
But you are not showing a lot of code, so we can't see how you are keeping track of the objects and what objects are really set to the ItemsSource of the list.
As you can see in my screenshot, when I just load a LongList with some data and add that same data ( note the word same here because it needs to be the same reference ), the are preselected in the emulator.
If you don't have the correct reference you can itterate the itemssource with linq and get them through some key if needed.
2 ways I pre selected items
this.LongListSelector.SelectedItems.Add(data1);
this.LongListSelector.SelectedItems.Add(this.LongListSelector.ItemsSource[2]);

Related

Primefaces selectManyMenu: Showing selected items on top of list

I'm using Primefaces' selectManyMenu to display a list of hundreds of items. I've also included a filter on top. The issue is that when I select, say, the 200th item in the list, I have to manually scroll down to the 200th item each time to see if it has been checked.
I want it so that whenever I select an item, it moves to the top of the menu, so that it is easy to view all the selected items from that list at the top without having to scroll down and up all the time.
Any suggestions?
Looks like your component is getting updated when selecting or unselecting an item, and that's the reason you're reloading the list and losing your scroll position.
Else, it looks like you could use a workround for this. Something like
Catch the select/unselect/change event and trigger a backing Bean function where
You rearrange you list of items sot that the selected ones will be pushed first
oncomplete, you will update your selectManyMenu component.
By the way, maybe it's time to think again if you're using the right component and UX practice. and I have the impression that selectManyMenu is not meant to be used with lists of 200+ items. Personally I think you should avoid using a list that will have to scroll down, for selectMany components. For example you could use another component like a pickList

UI Design of listboxes in windows phone 7?

in a page 4 menus one by one like the below.
APPS
1.sample1
2.sample2
PERSONAL
1.info1
2.info2
Valuble
1.item1
2.item2.
More
1.item1
2.item2
like the above APPS,PERSONAL,Valuble,More these are Headings.in that items are binding from Sqlite DB.
intially there are no items .DB is creating .by click on button in that page navigating to another page here i'm binding categories[APPS,PERSONAL---] to combobox and one textbox is there.in that way i'm adding items to mainpage.
functionalty is ok but i taken four listboxes statically placed in that i'm binding the items.but intially no items while db creation.if whenever adding the PERSONAL item first the first listbox was empty and filling the second listbox.if whenever adding MORE items first ,the above listboxes are empty this is bad design i think.
How to design UI for that...
I would have thought this is is an ideal candidate for the LongList selector control of Windows Phone - similar to the contacts page.
Have a look here http://www.windowsphonegeek.com/articles/wp7-longlistselector-in-depth--part1-visual-structure-and-api
I haven't used it myself but would think that you should be able to use it to get the effect you require.

Make no item selected in windows phone toolkit list picker

I'm using the ListPicker control from the WP7 Toolkit. I want to initially present the list with no items selected. Is there a way of doing this?
According to this blog entry List Picker works with the idea of "there is always an active selection".
The approach I would follow is to have the first item in the list be you "no selected item" item. With appropriate values (maybe a null id) that you can identify later on.
By design ListPicker must have a selected item. If you try to set it to null or set the SelectedIndex to -1 you will get an exception.

InfoPath 2007 - Populate drop-down list on-the-fly

I'm working on an InfoPath 2007 form. I have two drop-down lists and i need the second to be populated with items bases on the value chosen in the first list. I use c# to populate the drop-dpwn lists from external sources. I've tried to use the OnChange event to make all this, but the second list is still empty.
If anyone knows, please tell me.
You can filter the entries for the second drop-down list based on your first list (but only if the entries are based on a data source, not manually entered).
Bring up the properties window for
your second drop-down list.
Select your data source.
Click on the button to the right of the Entries text box.
Select the repeating node you wish to use for the basis of your list entry.
Click the Filter Data button. From here you can enter a filter to limit the entries displayed based on the value of your first drop-down list.
Your question was a bit ambiguous. You may be trying to populate a secondary data source based off of your first drop-down list. This should work fine with an OnChange event. Can you post the code you are using to do this?
Some additional tips that may help:
The change event will not fire until focus moves off of the list box. So, for the second drop down to populate, you will need to set the first drop-down then hit tab or click elsewhere in the form.
I don't know the size or nature of the data source you are using for the second drop-down list, but you may consider downloading the entire data source and filter it using the method I described above. This may be a better solution as you won't need to make a database query between entering the first list box and the second one.

Save Silverlight DataGrid sort

I have a Silverlight 2.0 DataGrid that contains a list of items that needs to be refreshed in an interval to display the up-to-the-minute information. There are items in this grid that may be added and may be removed while the screen is being displayed to the current user. For Example:
If grid looks like the following, then after a minute the data needs to be refreshed because another user has added a 4th entry. (notice the sort is assending by Last Name)
Data Grid http://img16.imageshack.us/img16/1667/datagrid.jpg
Then when I get the new data set and set it to the datagrid's DataSource property, it resorts the array based on my first column like so:
Data Grid2 http://img19.imageshack.us/img19/1294/datagridb.jpg
Is there any way to reapply the sort after the data source has been updated? I'd like to save the fact that the data grid is sorted by last name, then update the data source, and then reapply the sort to the data grid. So, in the end the datagrid would look like the following:
Data Grid3 http://img13.imageshack.us/img13/4636/datagrid2.jpg
These screen shots are of course not a Silverlight data grid, but this is for simplicity in explaining the situation.
Probably the best way to go about it is to use PagedCollectionViews, although I have not tested this out myself, these classes contain a property that stores the different sorting methods applied to them. I believe that you can probably grab the current sorting element from one collection, connect to the new collection, and apply the sorting to the new collection.
For a more in depth discussion on how this all works, you can follow the explanation here
I tried using PagedCollectionViews as well as CollectionViewSources (I used the new collection to overwrite the existing source collection).
My solution isn't the most elegant, but it works. When updating the source of the DataGrid I did my own change detection.
In other words, instead of blindly overwriting the source collection I iterated through the new collection, compared each item to the existing collection, and updated the existing items where possible.
Hope that helps.
After researching how to do this, I have figured it out. I tried to implement what the others said to try, but could not get it to work in Silverlight 2.0. Thus, I searched StackOverflow and Google for more answers. ScottLogic and CodeProject seemed to be what I was looking for but I couldn't get them to work fully. So with a bit of frustration and playing around with code, I finally arrived on the solution.
If the collection that you're using for your DataGrid's ItemsSource is ObservableCollection(Of T), you can get the ability of sorting for the object, plus you can update the collection dynamically at runtime, causing the grid to refresh with the item you insert. I've created a Google Code project that is GPL for you to checkout and download. Please note that I'm using the Microsoft Silverlight 2.0 DataGrid December 2008 Release for this project. I have linked to this download on the project page as well. (The dll's required are referenced from within a lib folder inside the project).
Enjoy!
Silverlight 2.0 DataGrid Sort Project on Google Code

Resources