Silverlight ListBox DataTemplate - silverlight-4.0

I have a Silverlight 4 ListBox with a created DataTemplate attached to it that correctly shows the items I want.
I would like to be able to have each Item in the list display differently according to a value in the object that is represented by the DataContext. I was originally looking at altering the DataTemplate on a per item basis, but I think my logic here is flawed.
What is the best way to approach this? Is a Listbox the best way to represent the collection given that I want a potentially different look per item?

I think ur looking for template selector in Silverlight .
Please follow below url http://www.codeproject.com/KB/silverlight/SLTemplateSelector.aspx
-Mahender

Related

VB.NET - How to Create Information Box

I'm creating a form that will display a long list of properties and their associated value. I'd like to display them in a sort of table-like control. Something with heading values at the top and a list of organized data underneath it. Something like these:
I realize those 2 examples aren't exactly the same but I'm flexible on what I produce as long as it gives a similar effect. My question is, how do I create a list like that? Is there a control in the Visual Studio toolbox that will produce this effect?
I'm sure there's something similar that easy to find but I can't figure out what to call that control so my searches haven't turned up anything useful.
Any help would be greatly appreciated. Thanks!
A combination of ListView and TabControl controls could be used to emulate what you're showing above. See the links for ListView and TabControl to help you get started.
Yes, there are windows form controls that provides this functionality.
For the tabbed windows use the TabControl:
For the different lists use a ListView control in the mode Details - which means a list with columns:
For the second feature, the ListView control has the Group features:
In order to group items togheter set the group for the chosen item(s):
All of this can be of course done programatically. There are good tutorials on MSDN and Channel9.

XAML control that supports data binding except listview or listbox

Is there any XAML control that supports data binding except listview or listbox. I am developing an application using windows azure mobile services table. After retrieving the data from table I am binding the list to a listview as a small preview. When user will select any Item from the list view I want to display the details of the selected item. Which XAML control will be suitable for this task. I can use lots of TextBoxes and assign its Text property from C# code. I dont think It is a good practice. Thank you
If it's a better collection viewer you are looking for for, use a DataGrid. If you want to show more info, it's worth making another panel and showing more data there about the selected item (master detail pattern)
All XAML controls support data bindings. Use DataContext if you want children to access the binding, otherwise you can bind directly on the property.
For example, you could have a separate panel that is a Grid with a few child controls. This Grid's DataContext can be set to the DataGrid's SelectedItem, then it's child controls can easily bind to the item's properties.

Synchronizing two ListViews in WinRT

I'm trying to synchronize the selected items of two different ListViews in a WinRT application, so that selecting an item(s) in one selects the same in the other. Both lists are bound to the same data source.
I thought that you could use the IsSynchronizedWithCurrentItem property of the ListView to manage synchronization, but this always seems to throw an exception when I try it ("Setting IsSynchronizedWithCurrentItem to true is not supported"), and anyway is perhaps not intended for use with multiple selected items.
Is there a way to programmatically select items in a given ListView in WinRT? Or what is the correct way to keep the selected items on two lists synchronized?
Take a look at the WinRT XAML Toolkit. It has a sample for ListViewExtensions in the samples app that seems to do almost exactly what you ask for.

Gridview with different template per datasource

I have a gridview that I would like to be able to bind to several sqldatasources, but still use template fields. Each datasource is different and would have different columns so I'm not sure how to go about this. Is it possible to define a set of template fields or overlying template per datasource?
The one way I can think of to do this would be to populate the GridView with rows dynamically from you datasources and then use the OnRowCreated event to switch the fields you want into template fields.
You can either extend the ITemplate interface or you can use a custom ascx control to load into the field like so.
TemplateColumn bc = new TemplateColumn();
bc.HeaderText = "Template Column";
bc.ItemTemplate = Page.LoadTemplate(TEMPLATEFILE);
grid.Columns.Add(bc);
Here are a few good links to help you out if you decide to take this road, really you may get better performance (and less maintainability headaches) from separating them out. Even update panels based on user input would be fine.
Link 1
Link 2
If you want to change your approach and your not sure about which option will suit you best try posting a bit more background about your project and we can go from there.
Happy Coding!
Personally with this it would sound more appropriate to have a separate datagrid control for each one.

Transparent ListBox or Listbox

I want set Listbox background to transparent but not working
Is there any idea?
As you've no doubt encountered it appears that you can't do this with a ListBox. One possible alternative (suggested here) is to use a list of Labels (which can be transparent) in place of a ListBox. It might not be practical for your situation but it's an option.
The exemple with label is a good idea if you don't want to use WPF. But, if you want to sort, the list a purpose to you to create a list with all the label name and create the number of label you need in a flowpanel. When you want to sort, you not sort the label, but the list, and after change the name of the label.
Ju
Best way is to use Windows presentation foundation ! (WPF)