2010-12-08 4 views
0

私は誕生日のカレンダーのための1つのサンプルアプリケーションをやっています。その中で、私は日付、月、年など3つのリストボックスコントロールを使用しています。私はそれにデータを追加listboxitemを使用してください。どのように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> 

、私はそれらのリストボックスの値を選択したいと私は(例:24-MAR-1988は意味= 24 + 03 + 88)を追加する必要があります。私はインデックス値を持っています。

int a = int.Parse((listBox1.SelectedIndex + 1).ToString());

I coudn't選択された値を取得:)(

列B = listBox1.SelectedItem.ToStringと、 MessageBox.Show(b);

答えて

2

Silverlight Toolkit for Windows Phoneを本当にお勧めします。それはDatePickerコントロールを持っています。

実際に自分のComboBoxコントロールを使用する場合は、少なくともC#で利用できるDateTimeタイプを使用することをおすすめします。

+0

はい、ツールキットコントロールを使用してください。 –

関連する問題