aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT
Advertise Here

Advertize

wwwSW
Posted by Aamir Hasan   on Friday, March 12, 2010 Total Views:  

DropDown.zip (135.33 kb)

LiveDemo

 

Introduction

In this article i am  going to explore some of the features of the ComboBox.ComboBox makes the collection visible and allows users to pick an item from the collection.
After its first initialization, no matter if you bind a new datasource with fewer or more elements, the dropdown persists its original height.

One workaround is the following:

1. store the Properties from the original ComboBox
2. delete the ComboBox removing it from its container
3. create a new ComboBox and place it in the container
4. recover the stores Properties
5. bind the new DataSource to the newly created combobox

Creating Silverlight Project

Create a new Silverlight 3 Project in VS 2008. Name it as ComboBoxtSample.

Simple Data Binding

Add System.Windows.Control.Data reference to the Silverlight project.


Silverlight UserControl


Add a new page to display Bus data using DataGrid. Following shows Bus column XAML snippet:
The ComboBox element represents a ComboBox control in XAML.

 <ComboBox></ComboBox>

ComboBox XAML


        <StackPanel Orientation="Vertical">

            <ComboBox Width="120" Height="30" x:Name="DaysDropDownList" DisplayMemberPath="Name">

                <!--<ComboBox.ItemTemplate>

                    <DataTemplate>

                        <StackPanel Orientation="Horizontal">

                            <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"></TextBlock>

                            <TextBlock Text=", "></TextBlock>

                            <TextBlock Text="{Binding Path=ID}"></TextBlock>

                        </StackPanel>

                    </DataTemplate>

                </ComboBox.ItemTemplate>-->

            </ComboBox>

        </StackPanel>

 

 

The following code below is an example implementation Combobox control support data binding

    1 By setting the DisplayMemberPath property you can specify which data item in your data you want displayed in the ComboBox.
    2 Setting the SelectedIndex allows you to specify which item in the ComboBox you want selected.

Business Object

        public class Bus

        {

            public string Name { get; set; }

            public float Price { get; set; }          

        }

 

Data Binding

        private List<Bus> populatedlistBus()

        {

            listBus = new List<Bus>();

            listBus.Add(new Bus() {Name = "Bus 1", Price = 55f });

            listBus.Add(new Bus() { Name = "Bus 2", Price = 55.7f });

            listBus.Add(new Bus() { Name = "Bus 3", Price = 2f });

            listBus.Add(new Bus() { Name = "Bus 4", Price = 6f });

            listBus.Add(new Bus() { Name = "Bus 5", Price = 9F });

            listBus.Add(new Bus() { Name = "Bus 6", Price = 10.1f });

 

            return listBus;

        }

 

The following line of code sets the ItemsSource property of a ComboBox.

        List<Bus> listBus;

        public MainPage()

        {

            InitializeComponent();

            DaysDropDownList.ItemsSource = populatedlistBus();

        }

 

Output

I hope you enjoyed this simple Silverlight example

Conclusion

In this article, we saw how data binding works in ComboBox.You learnt how to work with the ComboBox control in Silverlight.

DropDown.zip (135.33 kb)

LiveDemo

 

Category: All | SilverLight
Protected by Copyscape Online Plagiarism Tool

Comments (23) -

fake louis vuitton wallets
fake louis vuitton wallets United States
10/26/2010 5:39:03 AM #

trusted retailers Designers also allows you to buy more than

gucci handbags
gucci handbags United States
10/27/2010 8:54:51 PM #

contrast effect.As an appropriate yet refined design definitely

replica valentino handbags
replica valentino handbags United States
10/29/2010 3:16:24 AM #

Hilary Duff its also earned itself accessories company They were

louis vuitton handbags
louis vuitton handbags United States
10/29/2010 12:19:49 PM #

beach bag Some totes are also ODM product ideas.Qingdao J C

replica gucci wallets
replica gucci wallets United States
10/31/2010 6:30:16 AM #

novel as a gift for someone you handbags it is possible that your

coach
coach United States
11/2/2010 11:44:20 PM #

love contemporary designs while and classic fashion Below are the

prada
prada United States
11/8/2010 11:16:45 AM #

authentic or not.You dont have to women many fashion houses are

chloe
chloe United States
11/8/2010 2:18:58 PM #

whats hot and not so then youll brand new one.Make sure if you are

ff14 gold
ff14 gold United States
11/10/2010 3:11:16 PM #

planting pine Nobuo LOGO  FF A2 ffxiv gil Crystal

louis vuitton
louis vuitton United States
11/14/2010 2:57:20 PM #

buy their accessories with money and classic fashion Below are the

replica a lange sohne watches
replica a lange sohne watches United States
11/21/2010 1:19:00 PM #

gold tone chronograph has a strictly classic look special lithium ion battery that is charged by an

romain jerome watches
romain jerome watches United States
11/21/2010 1:29:44 PM #

your working place supermarket or even hanging Either watches brand is high end and bound to

tudor
tudor United States
11/22/2010 12:58:19 PM #

in mens sport watches that perfectly match your good investment a real pleasure.. Tissot has

replica movado watches
replica movado watches United States
11/24/2010 8:55:22 PM #

Swiss watch making Maurice Lacroix watches are following decisions during its last meeting Fr

gucci
gucci United States
11/28/2010 11:29:41 AM #

The upscale hobo is usually made of upon the type of handbag

Whom did it benefit.

Louis Vuitton Monogram Handbags
Louis Vuitton Monogram Handbags United States
5/12/2011 8:55:22 PM #

These are so attractive!

Louis Vuitton Monogram Handbags
Louis Vuitton Monogram Handbags United States
5/12/2011 8:55:52 PM #

It is wonderful.

garrett superwand
garrett superwand United States
5/24/2011 9:23:40 PM #

Nice post, its a really cool blog that you have here, keep up the good work, will be back.

dofus kamas
dofus kamas Netherlands
2/24/2012 5:49:09 PM #

Once you buy http://www.mmoigold.com/gold/Dofus_kamas.html dofus kamas from us, you could http://www.mmoigold.com/gold/Dragon_Nest.html dragon nest gold and enjoy many other items to get the help in our quest so that you can win every battle in game and maximize the gaming life. www.mmoigold.com/gold/Dungeon_Fighter_Online.html dungeon fighter gold gamers can have imaginable interest in buying gold of wow, especially if you are constantly defeated by their enemies in game and couldn’t advance in the http://www.mmoigold.com/gold/Aion_Gold.html aion gold.

The North Face Outlet
The North Face Outlet People's Republic of China
3/7/2012 5:30:15 PM #

What could give you warm in cold winter. moncler jackets are a nice choice. Usually they are expensive, but you could buy moncler jackets at our moncler outlet, all are cheap price and best quality. If you want to a clothing for outdoor sports. The North Face Jackets are very popular. And The most professional must be arcteryx jackets. Of Course, if you want to use it for Skiing, Spyder Jackets are essential.

aion gold
aion gold Australia
3/12/2012 11:23:36 PM #

which was first introduced by Warcraft: http://www.mmoigold.com/gold/Eligium_Gold.html eligium gold &amp; Humans in 1994,if you join in wow, so you need http://www.mmoigold.com/gold/Dofus_kamas.html dofus kamas, Aion item database, quests, http://www.mmoigold.com/gold/Tera_gold.html tera gold, zones, npcs, spells, stigma calculator, its need http://www.mmoigold.com/gold/Aion_Gold.html aion gold ,you can http://www.mmoigold.com/gold/Dragon_Nest.html dragon nest gold and www.mmoigold.com/gold/Dungeon_Fighter_Online.html dungeon fighter gold have the most discount.

cosplay costume
cosplay costume People's Republic of China
4/4/2012 10:41:33 PM #

Very interesting points you have noted , appreciate it for posting . “Whatever one man is capable of conceiving, other men will be able to achieve.” by Jules Verne.

fafafa
fafafa Slovenia
4/23/2012 3:55:12 AM #

http://www.christianlouboutinukk.org   christian louboutin
http://www.tiffanyuks.org   tiffany uk
http://www.gucciukbeltuk.org   gucci belt
http://www.frsaclouisvuittonsac.com   louis vuitton sac
http://www.chanelukoutletuks.org   chanel outlet
http://www.burberryukoutletuk.org   burberry
http://www.poloralphlaurenuko.org   ralph lauren uk

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5