Windows Phone Dropdown
I see that there is not a dropdown/combobox offered in t开发者_C百科he windows phone toolbox. I can see that there has to be a way to create one because in the settings of the phone, choosing a theme is essentially a dropdown menu.
Does anyone know where I can get sample code how to create one? I have seen a few samples, but the xaml seems really long and complicated. Is it really that difficult to create this control?
You can use the Silverlight for Windows Phone Toolkit (You really should be using this). The ListPicker Control will do what you want.
Here is an in-depth tutorial on how to use it: http://www.windowsphonegeek.com/articles/listpicker-for-wp7-in-depth
Here is a description of it (from here):
ListPicker
Comboboxes just aren't cool in WP7 dev. So use the ListPicker instead. Two formats available. The first expands in place to give you options. Useful for short lists. The second takes you over to another page witha full listbox to choose from then returns to the calling screen. You can see this in use on WP7 when you change Settings / Ringtones & Sounds.
Choosing a theme is actually creating a new page, and on selecting a color, it navigates back to the previous page with that value.
This is how I do this:
private void modelListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//if SelectedIndex == -1, do nothing
if(modelListBox.SelectedIndex == -1)
return;
//navigate to the MainPage
NavigationService.Navigate(new Uri
(String.Format("/views/MainPage.xaml?MakeIndex={0}&ModelIndex={1}", m_nCameraDataIndex, modelListBox.SelectedIndex),
UriKind.Relative));
//reset SelectedIndex
modelListBox.SelectedIndex = -1;
} //end method modelListBox_SelectionChanged
For a ddlist, I found this:
http://www.simego.com/Blog/2008/05/combobox-dropdo
精彩评论