I am very new on WP programing, I worked with Borland Delphi / PHP / MySQL before..
I want to have combobox or listbox (i know there is no combobox for WP8 any more :( )
I try many options, but my listbox doesn't appear in screen. buttons, text's are all okay by list box never show up at runtime. and also don't get any error on compiler.
Could you help me step by step how to create a combobox / list box for following items:
C,C#,D,D#,E,F,F#,G,G#,A,A#,B
I want to have these in a list, and when user selects one of it i will make some Musical Scale options starting with the key he choose for user.
if you could explain me for WP8:
- how to define list box in MainPage.xaml
- how to create binding
- how to define list in MainPage.xaml.cs and bind to listbox
I install toolkit and try listpicker also, but didn't work eihter.
I add the parts i tried: Hi, in MainPage.xaml i write this code as last try:
<ListBox ItemsSource="{Binding ScaleSharpx}" Width="50" Background="Blue">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding text}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
and in MainPage.xaml.cs i tried these
public String[] ScaleSharpx = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
nothing appears on page
if i try this:
<ListBox x:Name="D1" ItemsSource="{Binding}" Width="50" Background="Blue">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding text}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
and then add this code to MainPage.xaml.cs
this.D1.ItemsSource = ScaleSharpx;
i got error message that,
{System.InvalidOperationException: Items collection must be empty before using ItemsSource. at System.Windows.Controls.ItemsControl.set_ItemsSource(IEnumerable value) at Scale_Finder.MainPage..ctor()} System.Exception {System.InvalidOperationException}
ItemsSource={Binding}
or assign ItemsSource from code :D1.ItemsSource = ScaleSharpx;
. Don't do both at a same time and don't add items manually to listbox :D1.Items.Add(...)
. Try to fix this one first, then see what problem remains. – har07D1.Items
doesn't contain any items, as I said, never add item directly toD1.Items
or declare listboxitem in XAML. – har07