RadMenu per RadGridView Row?

3 posts, 1 answers
  1. Chris
    Chris avatar
    9 posts
    Member since:
    Sep 2011

    Posted 30 Sep 2011 Link to this post

    Hi all,

    (I have cross-posted this to the two relevant forums)

    Is it possible to have a RadMenu per RadGridView row? I have a Windows explorer-style interface with a tree view on the left and a RadGridView on the right providing a listview style view. The commands for each of my items can vary. In the tree they are data bound to a RadMenu at runtime. Is there a way of doing this per row in a RadGridView?

    The only sample I have found shows a menu for the entire grid, not per row.

    I have tried per column by putting a menu inside the CellTemplate alongside the other controls but get a memeory vialoation error!

    Any tips or tricks would be appreciated.

    Cheers,
    Chris.

  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Sep 2011 Link to this post

    Hello Chris,

     You can use single menu for the whole grid however provide different items using Opened event. In this demo items are static however you can do the same with dynamic items. 

    Best wishes,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Chris
    Chris avatar
    9 posts
    Member since:
    Sep 2011

    Posted 30 Sep 2011 Link to this post

    Hi

    Thanks for the reply, it is a possible solution.

    However, I have just realised I was missing a converter and that is why my xaml was invalid. The code below now seems to work for me. I suppose this means I would need to do it for eaxch column though so not ideal.

    Thanks,
    Chris.
    <telerik:GridViewDataColumn Header="Name">           
        <telerik:GridViewDataColumn.CellTemplate>               
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <telerik:RadContextMenu.ContextMenu>
                        <telerik:RadContextMenu x:Name="ContextMenu" StaysOpen="False"
                                ItemsSource="{Binding NavigationCommands}" ItemTemplate="{StaticResource ContextMenuItemTemplate}">
                        </telerik:RadContextMenu>
                    </telerik:RadContextMenu.ContextMenu>
                    <Image Source="{Binding Category, StringFormat='../Resources/Images/Icons/\{0\}_16.png'}" Width="16" Height="16" Margin="0,0,5,0"/>
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>          
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>

Back to Top