[英]Get current selected item in listview
How can I display the currently selected item and its price in a message box? 如何在消息框中显示当前选中的商品及其价格?
<ListView Name="listMenuItems" SelectionMode="Multiple" Background="Transparent" SelectionChanged="listMenuItems_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Border Width="700" Height="80" CornerRadius="5" BorderBrush="Gray" BorderThickness="2">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Red" Direction="200" Noise=".6" ShadowDepth="10" Opacity=".6"/>
</Border.BitmapEffect>
<TextBlock Name="txtItem" Height="100" Width="650" FontSize="50" Text="{Binding Path=item}" FontFamily="Georgia"></TextBlock>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
var tempitem=((YourCustomClass)e.ClickedItem).item;
您需要在listview Itemclick事件中进行类型转换,然后才能访问选定的项目和价格(因此无法在代码中找到其绑定,因此假设)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.