Domain Up Down Control In Silverlight 3 Application

No.of Views583
Bookmarked0 times
Downloads 
Votes0
By  dpatra   On  16 Feb 2010 00:02:01
Tag : Silver Light and XAML , How to
Domain Up Down Control In Silverlight 3 Application
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 Introduction
In this article we will see how can we use DomainUpDown Control available in Silverlight 3 Toolkit.

Crating Silverlight Project
Fire up Visual Studio 2008 and create a Silverlight Application. Name it as DomainUpDownInSL3.


Image Loading....

Go ahead and add a DomainUpDown control and name it as MyDomainUpDown.
I have designed the page as follows:

Image Loading....

Now what we need is a collection of sample data.Create a class and name it as States.cs

Add the following properties:

{codecitation class="brush: csharp; gutter: true;" width="650px"}

public class States
{
public string State { get; set; }
public string Capital { get; set; }
public string Short { get; set; }
public string Language { get; set; }
}



{/codecitation}

Now we need to make a data template of the DomainUpDown control and bind properties to it.

{codecitation class="brush: xml; gutter: true;" width="650px"}

<inputToolkit:DomainUpDown x:Name="MyDomainUpDown" HorizontalAlignment="Left" ValueMemberPath="Short" Height="75" FontSize="34" Grid.Column="1" Grid.Row="1">
<inputToolkit:DomainUpDown.ItemTemplate>
<DataTemplate>
<Grid MinWidth="370">
<Grid.Background>
<SolidColorBrush Color="#aa000000" />
</Grid.Background>
<TextBlock Foreground="#22ffffff" Margin="4+0,2+0" FontSize="34" Text="{Binding Short}" />
<StackPanel HorizontalAlignment="Right" Margin="0, 0, 8, 0">
<TextBlock HorizontalAlignment="Right" Foreground="White" FontSize="12" Text="{Binding Capital}" Padding="2" />
<TextBlock HorizontalAlignment="Right" Foreground="White" FontSize="14" Text="{Binding Language}" Padding="2" />
<TextBlock HorizontalAlignment="Right" Foreground="White" FontSize="14" Text="{Binding State}" Padding="2" />
</StackPanel>
</Grid>
</DataTemplate>
</inputToolkit:DomainUpDown.ItemTemplate>
</inputToolkit:DomainUpDown>



{/codecitation}

Now we will create a sample list of data and assign the ItemSource of the DomainUpDown control to it:

{codecitation class="brush: csharp; gutter: true;" width="650px"}

public MainPage()
{
InitializeComponent();
List<States> myList = new List<States>
{
new States{ State="Andhra Pradesh", Capital="Hyderabad", Short="AP", Language="Telugu and Urdu"},
new States{State="Arunachal Pradesh" , Capital="Itanager", Short="ARP", Language="Miji, Apotanji, Merdukpen, Tagin,Adi"},
new States{State="Assam" , Capital="Dispur", Short="AS", Language="Assamese"},
new States{State="Bihar" , Capital="Patna", Short="BH", Language="Hindi"},
new States{State="Chhattisgarh" , Capital="Raipur", Short="CH", Language="Hindi"},
new States{State="Goa" , Capital="Panaji", Short="GO", Language="Marathi and Konkani"},
new States{State="Gujarat" , Capital="Gandhinagar", Short="GUJ", Language="Gujarati"},
new States{State="Haryana" , Capital="Chandigarh", Short="HAR", Language="Hindi"},
new States{State="Himachal Pradesh" , Capital="Shimla", Short="HP", Language="Hindi and Pahari"},
new States{State="Jammu & Kashmir" , Capital="Srinagar, Jammu", Short="JK", Language="Kashmiri,Dogri, Urdu, Ladakhi"},
new States{State="Jharkhand" , Capital="Ranchi", Short="JH", Language="Hindi"},
new States{State="Karnataka" , Capital="Bangalore", Short="KR", Language="Kannda"},
new States{State="Kerala" , Capital="Trivandrum", Short="KL", Language="Malayalam"},
new States{State="Madhya Pradesh" , Capital="Bhopal", Short="MP", Language="Hindi"},
new States{State="Maharashtra" , Capital="Bombay", Short="MH", Language="Marathi"},
new States{State="Manipur" , Capital="Imphal", Short="MN", Language="Manipuri"},
new States{State="Meghalaya" , Capital="Shillong", Short="MG", Language="Khasi, Jaintia and Garo"},
new States{State="Mizoram" , Capital="Aizawl", Short="MZ", Language="Mizo and English"},
new States{State="Nagaland" , Capital="Kohima", Short="NG", Language="Ao, Konyak, Angami, Sema and Lotha"},
new States{State="Orissa" , Capital="Bhubaneswar", Short="ORI", Language="Oriya"},
new States{State="Punjab" , Capital="Chandigarh", Short="PN", Language="Punjabi"},
new States{State="Rajasthan" , Capital="Jaipur", Short="RJ", Language="Rajasthani and Hindi"},
new States{State="Sikkim" , Capital="Gangtok", Short="SK", Language="Bhutia, Hindi, Nepali, Lepcha, Limbu"},
new States{State="Tamil Nadu" , Capital="Chennai", Short="TN", Language="Tamil"},
new States{State="Tripura" , Capital="Agartala", Short="TR", Language="Bengali, Tripuri, Manipuri, Kakborak"},
new States{State="Uttar Pradesh" , Capital="Lucknow", Short="UP", Language="Hindi"},
new States{State="Uttaranchal" , Capital="Dehra Dun", Short="UC", Language="Hindi"},
new States{State="West Bengal" , Capital="Kolkata", Short="WB", Language="Bengali"}
};
MyDomainUpDown.ItemsSource = myList;
}

{/codecitation}

That’s it. Now run your application and you will find the following screen:

Image Loading....

The good thing about this control is that when it reaches at the beginning or at the end the button gets disabled.
Enjoy Coding.


About the Author


Diptimaya Patra

Description :I am a Master in Computer Application (MCA) from SRM University, Chennai. I am MCTS in ASP.Net Web Development, and MOSS 2007 Administration. I have extreme exposure to Microsoft Technologies in recent times like Silverlight 2, Silverlight 3. I am from Cuttack, Orissa. You can reach me using this mail (diptimaya.patra@gmail.com). Currently I am working as a Software Engineer in UST Global Inc in Trivandrum Center.

Occupation :Software Engineer
Company : UST Global.
Location : India
Follow me at twitter : http://twitter.com/dpatra


 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top