Action Controls


Another user interface control that you can use is CheckBox. The CheckBox control offers a property called Content that you can use to add descriptive text. By default it supports typical checked and unchecked states. You can also set the CheckBox to behave in three state modes that are Checked, Unchecked, and Indeterminate. Following is the declaration of a CheckBox control that uses all three states:

<CheckBox x: Name="…" Content="…" Checked="… " Unchecked="…" IsThreeState="True"/>


The ComboBox control provides you a way to give your users a choice of options to select from. Almost all the development environments offers some form of this control, whether it is a <select> tag in HTML or the DropDownList control in ASP.NET. Like those of the other controls, ComboBox consists of the ComboBoxItem control to hold the item objects. Following XAML code declares an instance of a ComboBox that contains several option choices:

        <ComboBox x: Name="Students">
         <ComboBoxItem Content="Afsar Murad"/>
         <ComboBoxItem Content="Steve"/>
         <ComboBoxItem Content="Hanan"/>
         <ComboBoxItem Content="Peter"/>
         <ComboBoxItem Content="Jhone"/>
         <ComboBoxItem Content="Select Item" IsSelected="True"/>

For now you have noticed that how the ComboBoxItem objects make use of the Content property to define what displays upon selection. For the determination which item should be selected by default, you have to set the IsSelected property “true” for the proper ComboBoxItem object. Now when a selection has been made and you need to perform logic behind your selection, you can set up an event handler for the SelectionChanged event. This event handler offers you with an AddedItems collection that you can use to extract the selected ComboBoxItem. The code for the selected ComboBox option is as follows:

private void BasicCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
ComboBoxItem selected = e.AddedItems[0] as ComboBoxItem;
if (selected != null && SelectedComboItem != null)
SelectedComboItem.Text = String.Format("Selected Item: {0}",
Action Controls Action Controls Reviewed by Afsar Murad on 02:11 Rating: 5
Powered by Blogger.