如标题所示,我有一份附有背景的清单箱。 我试图从名单箱的条目中获取价值。 现行法典如下:
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#90361F" BorderThickness="3" CornerRadius="5" Margin="5">
<StackPanel Orientation="Vertical" Background="#90361F" Width="488">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu Tag="{Binding .}">
<toolkit:MenuItem Click="MenuItemDelete_Click" Header="Delete Timer"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<StackPanel Orientation="Vertical" Background="#90361F" Width="488" >
<TextBlock Text="{Binding e2name}" Foreground="White" FontSize="25"/>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="{Binding name}" Foreground="White" FontSize="15" Tag="{Binding name}"/>
<TextBlock Text="{Binding datetime}" Foreground="White" FontSize="15" HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在情况简介会点击事件
private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
{
var me = ((FrameworkElement)sender).Tag as ListBoxItem;
}
i m trying to get the value from the binding of name, i m also using a tag to try and pass the data. as you can see from my click event, well it s pretty rubbish! From what i ve read and understand i do need to make use of ((FrameworkElement)sender).Tag but i m not sure on how to init it. thanks