This question is locked. New answers and comments are not allowed.
Hi,
I try to get the ContextMenu.GetClickedElement() Element when clicking on a ListBoxItem, whose ListBox is nested in a RadPanelBarItem.
XAML:
I want to get the DataContext of the ListBoxItem clicked. For that I use this Code:
But Me.contextMenuTemplate.GetClickedElement(Of ListBoxItem)() always returns nothing!
If I try RadPanelBarItem instead of ListBoxItem for the Type in GetClickedElement i get the ListBox but not the ListBoxItem.
Am I missing something?
How can I retrieve the ListBoxItem clicked in the contextMenue_Open event?
thanks in advance
Lukas
I try to get the ContextMenu.GetClickedElement() Element when clicking on a ListBoxItem, whose ListBox is nested in a RadPanelBarItem.
XAML:
| <Canvas> |
| <telerikN:RadContextMenu.ContextMenu> |
| <telerikN:RadContextMenu x:Name="contextMenu" ItemClick="contextMenu_ItemClick" Opened="contextMenu_Opened"> |
| <telerikN:RadMenuItem Header="Löschen" x:Name="delete"/> |
| </telerikN:RadContextMenu> |
| </telerikN:RadContextMenu.ContextMenu> |
| <telerikN:RadPanelBar Name="rpb_Vorlagen" HorizontalAlignment="Stretch" Width="505"> |
| <telerikN:RadPanelBarItem Header="Administrative Vorlagen" IsExpanded="True" FontWeight="ExtraBold" FontSize="14"> |
| <ListBox HorizontalAlignment="Left" Width="498" MaxHeight="215" Name="lbx_TemplatesAdmin" VerticalAlignment="Top" Background="{StaticResource ControlBrush}"> |
| <ListBox.ItemTemplate> |
| <DataTemplate> |
| <RadioButton GroupName="grp1" Content="{Binding Name}" Checked="CheckBox_Checked" IsChecked="{Binding isChecked,Mode=TwoWay}" FontWeight="Normal" FontSize="12" /> |
| </DataTemplate> |
| </ListBox.ItemTemplate> |
| </ListBox> |
| </telerikN:RadPanelBarItem> |
| </telerikN:RadPanelBar> |
| </Canvas> |
I want to get the DataContext of the ListBoxItem clicked. For that I use this Code:
| Private Sub contextMenu_Opened(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) |
| Dim buf = Me.contextMenu.GetClickedElement(Of ListBoxItem)() |
| If buf IsNot Nothing Then _selectedItem = TryCast(buf.DataContext, DPTemplate) |
| If _selectedItem Is Nothing Then |
| contextMenuTemplate.IsOpen = False |
| End If |
| End Sub |
But Me.contextMenuTemplate.GetClickedElement(Of ListBoxItem)() always returns nothing!
If I try RadPanelBarItem instead of ListBoxItem for the Type in GetClickedElement i get the ListBox but not the ListBoxItem.
Am I missing something?
How can I retrieve the ListBoxItem clicked in the contextMenue_Open event?
thanks in advance
Lukas