Translate

> > Silverlight Combobox (static / dynamic) value get set

Silverlight Combobox (static / dynamic) value get set

Posted on Tuesday, March 18, 2014 | No Comments

Static Data combobox


                    <ComboBox Grid.Column="3"
                              Grid.Row="7"
                              Name="cmbMariedStaus"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Top"
                              Style="{StaticResource ComboboxEntryStyle}">

                        <ComboBox.Items>
                            <ComboBoxItem>Married</ComboBoxItem>
                            <ComboBoxItem>Un married</ComboBoxItem>
                        </ComboBox.Items>
                    </ComboBox>


Value GET :   (cmb.SelectedItem as ComboBoxItem).Content.ToString();
Value Set :   cmb.SelectedItem = cmb.Items.SingleOrDefault(c => (c as ComboBoxItem).Content.ToString() == values);

Dyanamic Data Combobox

<ComboBox Grid.Column="1"
                              Grid.Row="9"
                              Name="cmbDepartment"
                              ItemsSource="{Binding}"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Top"
                              DisplayMemberPath="DepName"
                              SelectedValuePath="DepID"
                              Style="{StaticResource ComboboxEntryStyle}">
                    </ComboBox>

Value GET : cmbDepartment.SelectedValue.ToString();

Vale Set : cmbDepartment.SelectedValue = "some value";

Leave a Reply

Powered by Blogger.