c# - What is the best approach to creating a "list of contacts" in Silverlight? -
I'm trying to create a Silverlight application that pulls me into my Flickr contact and photo, I "well" I want to display that I intend to make a control that shows users and their images next to their name. I want each user to be listed one after another. Something like this:
---------------------------- Username: & lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; ---------------------------- Username: & lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; ---------------------------- Username: & lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; ---------------------------- Username: & lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; ---------------------------- Username: & lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; & Lt; Photo & gt; ---------------------------- I was able to dynamically create and get it I want to be there if a scrollbar is visible when necessary (hence the user can scroll up and down).
What is the best way to make something like this? Is there any control or technique that I should follow?
In fact, many nested listboxes you want a list box.
First of all, get your data in a structure that will work well with Silverlight (and I'm assuming Silverlight2 here). For this I have a
Observeable Collection & lt; Contacts & gt; Where contact is your class that represents a contact. That class should be one
OverviewCollection & lt; Flickr Photo & gt; As a property.
Here is the structure of XAML you can potentially transfer templates to resources, or you can create a user control to capture each list item.
& lt ;! - Required - SilverlightToolkit for WrapPanel - & gt; & Lt ;! - xmlns: tk = "clr-namespace: system. Windowscontrols; assembly = system. Windows control .tollkit" - & gt; & Lt; List Box Itemsource = "{Binding}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Grid width = "400" & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "*" /> & Lt; Column width = "*" /> & Lt; /Grid.ColumnDefinitions> & Lt; Text block grid Column = "0" text = "{binding user name}" /> & Lt; ListBox Grid.Column = "1" ItemSource = "{Binding Flickr Photo}" ScrollViewer.HorizontalScrollBarVisibility = "Disabled" & gt; & Lt; ListBox.ItemsPanel & gt; & Lt; ItemsPanelTemplate & gt; & Lt; T: WrapPanel / & gt; & Lt; / ItemsPanelTemplate & gt; & Lt; /ListBox.ItemsPanel> & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Image source = "{binding photo}" width = "80" /> & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt; & Lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt; Notes:
- This code is a very difficult example
- You need to force the horizontal scrollbar to be disabled on the listbox. Wrap for
- You have to set the datacentext of the external listbox (or ancestors control) in the collection of your contacts.
Comments
Post a Comment