How to fetch item

2 posts, 0 answers
  1. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 13 Aug 2013 Link to this post

    I have a ListBox that contains data bound TextBoxes. The TextBox has a Context Menu.

    In my Tapped event handlers, I can't figure out how to access the TextBox, and it's bound element, that the user long pressed on (it may or may not be selected, so I can't just use the ListBox). The ContextMenu documentation says to use GetElementUnderMenu(), but I can't find any documentation or examples on how to use it.

    Any help or suggestions would be greatly appreciated.

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel>
                <TextBlock TextWrapping="Wrap" Text="{Binding Path=LocalizedResources.ProfilesPageInstructions, Source={StaticResource LocalizedStrings}}" Height="104" HorizontalAlignment="Center"/>
                <ListBox x:Name="listBox">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel x:Name="sp">
                                <TextBlock Text="{Binding profileName}" FontSize="{StaticResource PhoneFontSizeLarge}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <telerikPrimitives:RadContextMenu.ContextMenu>
                        <telerikPrimitives:RadContextMenu OpenGesture ="Hold" x:Name="menu" Opening="OnMenuOpening"  IsFadeEnabled="True" IsZoomEnabled="True" >
                            <telerikPrimitives:RadContextMenuItem Content="delete" Tapped="deleteTapped"/>
                            <telerikPrimitives:RadContextMenuItem Content="rename" Tapped="renameTapped"/>
                        </telerikPrimitives:RadContextMenu>
                    </telerikPrimitives:RadContextMenu.ContextMenu>
                </ListBox>
            </StackPanel>
        </Grid>
    </Grid>
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Aug 2013 Link to this post

    Hello David,

    Thank you for contacting us. I'd strongly suggest you take a look at the ContextMenu examples which are part of the Telerik Examples. The example (FirstLook) demonstrates how to use a context menu in combination with RadDataBoundListBox.
    Another option would be to get your hands on the source code of the example which is located under C:\Program Files (x86)\Telerik\RadControls for Windows Phone 8 Q2 2013\Examples after installing the RadControls for Windows Phone 8 suite.

    Give it a try and let me know how it works for you.

    Regards,
    Kiril Stanoev
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
Back to Top