om prakashRank #5,816 · 285 reputationPosted Sep 26, 2013, 3:55 AM EDT
0
i want the value to be display defaultltty i no that after clicking combox box certain values will be displayed while page load itself i need to see the values
Hi, 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.
Jeetendra GundRank #97 · 22.1K reputationPosted Sep 25, 2013, 11:14 PM EDT
Here refer this link it will help you,
http://stackoverflow.com/questions/6149671/silverlight-default-value-in-combobox
Thanks,
om prakashRank #5,816 · 285 reputationPosted Sep 26, 2013, 3:55 AM EDT
om prakashRank #5,816 · 285 reputationPosted Sep 26, 2013, 4:02 AM EDT
Jeetendra GundRank #97 · 22.1K reputationPosted Sep 26, 2013, 9:14 PM EDT
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.
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 26, 2013, 9:37 PM EDT
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");
}
}
}
om prakashRank #5,816 · 285 reputationPosted Sep 27, 2013, 12:40 AM EDT
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 LenkaRank #301 · 8.3K reputationPosted Sep 27, 2013, 12:49 AM EDT
just write this:
HourTypes.SelectedIndex = 0;
om prakashRank #5,816 · 285 reputationPosted Sep 27, 2013, 12:50 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 27, 2013, 12:53 AM EDT
om prakashRank #5,816 · 285 reputationPosted Sep 27, 2013, 12:57 AM EDT
om prakashRank #5,816 · 285 reputationPosted Sep 27, 2013, 1:35 AM EDT
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
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 27, 2013, 2:08 AM EDT
if possible attached your project sample here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts