silverlight 3.0 - Custom Listbox: Limit Maximum Item Count -
I have a Silverlight 3.0 project that has a listback which is databased in the list of items. What I want to do is to limit the number of items listed in the list. & Lt; = 10. I basically completed it by doing 10 items to limit the data bound to the list. Take on my orignal data (10) and find out the result
The problem w /. (10) The approach is that the original data source can change and later. Retract the original data reference (or not sure copy) (I) Sometimes the changes do not appear in the figures reflected in my UI.
I am trying to figure out a better way to deal with this. It seems that if you have more than one UI element associated with the same data, then you should not 'filter' your data using LINQ functions. I only have the idea of how to do it better, to make a custom container to limit the count, but it seems that it could be a mountain of work to make a custom stackpanel or equivalent.
take (10)
does not copy, Adds one more step for it. But all execution is postponed till no person pulls the query items.
If you are setting up the item steady, the question will be created once a copy once actually made a copy. But since you set the construction query as the ItemsSource
property of the list box, it can run and update at any time, so this is the right way.
The real reason for this is that sometimes you do not see any changes in the data reflected in the UI, there is no way in determining why the data returned from the query has changed in the list box and it is definitely Do not want to try to refresh the data again and try to update itself. You need to tell this.
How can you tell it? Documentation for Item Source
says that " You must set itemsSource
in an object that implements the INotifyCollectionChanged
interface so that the archive Changes in will be reflected (...). "The default way of working apparently Net does not work in your case.
Then there are some examples of how you implement yourself eg If the top level source data collection (which you are querying the LINQ) does not support these notifications (which you will proceed), then you may need to update the list box manually with your second code. Which changes the underlying data.
Comments
Post a Comment