1.aa
2.bb
3.cc
before i selecting any value of above three aa must be displayed in combo box..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Sep 27, 2013, 6:08 AM
if possible attached your project sample here.
om prakashPosted Sep 27, 2013, 5:35 AM
csFile:
i want to bind my enum here only "normal Time" while page loading after that while clicking combo box i want to select other enum values
om prakashPosted Sep 27, 2013, 4:57 AM
Sanjeeb LenkaPosted Sep 27, 2013, 4:53 AM
om prakashPosted Sep 27, 2013, 4:50 AM
Sanjeeb LenkaPosted Sep 27, 2013, 4:49 AM
just write this:
HourTypes.SelectedIndex = 0;
om prakashPosted Sep 27, 2013, 4:40 AM
HourTypes = new EnumToDropdownMapper().Map
// string ss = HourTypes.ToList()[0].Description;--i checked this for sample
Enum code:
public enum HourType
{
[EnumDisplayName("Normal Time")]
NormalTime,
[EnumDisplayName("Over Time")]
OverTime,
[EnumDisplayName("Double Time")]
DoubleTime
}
Xaml Code:
SelectedValuePath="Value" SelectedValue="{Binding SelectedHourType}"
Grid.Row="6" Grid.Column="1" />
i want to bind (normal TIme) in combo box defautly when the page is loaded can u help me..
Sanjeeb LenkaPosted Sep 27, 2013, 1:37 AM
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
combobind();
comboBox1.SelectedIndex = 0;
}
public void combobind()
{
comboBox1.Items.Add("aa");
comboBox1.Items.Add("bb");
comboBox1.Items.Add("cc");
}
}
}
Jeetendra GundPosted Sep 27, 2013, 1:14 AM
If u r using silverlight5 or if u r using mvvm mode in that then u can do this by using binding like as
in this case you have to bind your collection to "ItemsSource" property and make single value of same collection and bind this single to "SelectedItem" property. And keep mode in "TwoWay"
Set that single property in viewmodel to any value of collection.
om prakashPosted Sep 26, 2013, 8:02 AM
om prakashPosted Sep 26, 2013, 7:55 AM
Jeetendra GundPosted Sep 26, 2013, 3:14 AM
Here refer this link it will help you,
http://stackoverflow.com/questions/6149671/silverlight-default-value-in-combobox
Thanks,