Ich mache eine Beispiel-App für Geburtstagskalender. In diesem verwende ich drei Listbox-Steuerelement wie Datum, Monat und Jahr. Mit listboxitem habe ich Daten hinzugefügt.Wie wählt man die Listbox Werte in Windows Phone 7?
<ListBox Height="56" HorizontalAlignment="Left" Margin="243,171,0,0" Name="listBox1" VerticalAlignment="Top" Width="207">
<ListBoxItem Content="01" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="02" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5"/>
<ListBoxItem Content="03" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="04" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="05" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="06" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="07" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="08" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="09" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="10" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="11" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="12" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="13" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="14" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="15" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="16" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="17" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="18" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="19" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="20" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="21" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="22" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="23" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="24" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="25" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="26" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="27" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5"/>
<ListBoxItem Content="28" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="29" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="30" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
<ListBoxItem Content="31" HorizontalContentAlignment="Center" IsSelected="True" VerticalContentAlignment="Center" FontSize="32" FontWeight="Bold" FontFamily="Segoe WP Bold" BorderThickness="5" />
</ListBox>
so, ich will diese Listbox Werte auszuwählen und ich muss hinzufügen (zB: 24-MAR-1988 Mittel = 24 + 03 + 88). Ich habe Indexwert.
int a = int.Parse ((listBox1.SelectedIndex + 1) .ToString());
I coudn't ausgewählten Wert erhalten:
String b = listBox1.SelectedItem.ToString(); MessageBox.Show (b);
Ja, verwenden Sie das Toolkit-Steuerelement. –