dam*_*atx 3 xaml listbox windows-phone-7
我在我的xaml页面上有一个名为MainListBox的ListBox.我可以获得被选中的索引,但是如何从所选项中获取数据?
我的MainListBox_SelectionChanged:
private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int noteID1 = MainListBox.SelectedIndex+1;
if (MainListBox.SelectedIndex != null)
{
//I can get the index that get selected,
Debug.WriteLine(MainListBox.SelectedIndex);
}
MainListBox.SelectedIndex = -1;
}
Run Code Online (Sandbox Code Playgroud)
我的XAML:
<ListBox x:Name="MainListBox" Margin="6,0,0,0" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged" Height="578" VerticalAlignment="Bottom" Grid.ColumnSpan="3">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432">
<TextBlock x:Name="ItemText" Text="{Binding noteName}" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock x:Name="DetailsText" Text="{Binding noteText}" Margin="10,-6,0,3" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock x:Name="noteIdText" Text="{Binding noteID}" Margin="10,-6,0,3" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
请有人指导我,谢谢.:)
你试过MainListBox.SelectedItem吗?
var data = MainListBox.Selecteditem as [class of class to classbox];
| 归档时间: |
|
| 查看次数: |
7340 次 |
| 最近记录: |