ListBoxItem item = list1.SelectedItem as ListBoxItem;SelectedItemの値は、ここではListBoxItemにキャストします。後は、そこからContentを取り出して処理するだけです。ComboBoxがわかれば、ListViewもほとんど同じ感覚で扱えるでしょう。
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※MainPage.XamlのListViewのタグ
<ListView x:Name="list1" HorizontalAlignment="Left" Height="252" Margin="113,182,0,0"
VerticalAlignment="Top" Width="307" FontSize="24" Background="#FF660000"
SelectionChanged="List1_Changed">
<ListBoxItem Content="Windows Phone" FontSize="24"/>
<ListBoxItem Content="Android" FontSize="24"/>
<ListBoxItem Content="iPhone" FontSize="24"/>
<ListBoxItem Content="Black berry" FontSize="24"/>
</ListView>
※MainPage.Xaml.csに作成されるメソッド
vate void List1_Changed(object sender, SelectionChangedEventArgs e)
{
ListBoxItem item = list1.SelectedItem as ListBoxItem;
string msg = "you seleted: " + "\"" + item.Content + "\"";
textblock1.Text = msg;
}
| << 前へ | 次へ >> |