Telerik Forums
UI for WPF Forum
0 answers
21 views

Hello

Please check the attached file: contextmenu.png
I want the 1st row icon column to have Padding=0,0 and Margin=0,0,0,0

Waiting for your reply

anna
Top achievements
Rank 1
Bronze
Iron
 updated question on 28 Apr 2025
0 answers
34 views

WPF, RadContextMenu

Is there a way to display different colors in the RadContextMenu ?

Display RadContextMenu various colors based on the Separator of RadContextMenu.

In RadContextMenu,

Also, can you set the image margin(or icon margin) to 0?

Please check the attached file : RadContextMenu2WPF.png, RadContextMenu1WPF.png

anna
Top achievements
Rank 1
Bronze
Iron
 asked on 17 Apr 2025
1 answer
57 views

None of the examples you guys have or I've been able to find are a solution to what should be an easy problem.  Right-click on a grid row, show the context menu, and when the user selects an items from the context menu, pass the id from the row to the page view model.

I did find this post but because it uses a UI element for the binding path and it uses code behind instead of MVVM, it's not a solution but my code is based on this.

MVVM RadGridView -> RadContextMenu -> RadMenuItem -> CommandParameter: get the row? in UI for WPF | Telerik Forums

Here is my context menu code.

<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow">
        <Setter Property="telerik:RadContextMenu.ContextMenu">
            <Setter.Value>
                <telerik:RadContextMenu>
                    <telerik:RadMenuItem Header="Open"
                                         Command="{Binding OpenCommand}"
                                         CommandParameter="{Binding Path=.}" />
                    <telerik:RadMenuItem Header="Delete"
                                         Command="{Binding DeleteCommand}"
                                         CommandParameter="{Binding Path=.}" />
                    <telerik:RadMenuItem Header="Print"
                                         Command="{Binding ReportCommand}"
                                         CommandParameter="{Binding Path=.}" />
                </telerik:RadContextMenu>
            </Setter.Value>
        </Setter>
    </Style>
</telerik:RadGridView.RowStyle>

The problem is it thinks the commands are in the view model for the grid row data so I'm getting binding failures. 

DeleteCommand property not found on object of type JobVm.

 

I need to have it use the commands in my page view model.  How can I achieve this?  I've tried dozens of combinations of setting the RelativeSource but none of them seem to work.

 

 

 

 

Stenly
Telerik team
 answered on 03 Feb 2025
1 answer
98 views

Hi,

What I'm tryin to do is create an App that starts hidden (without a RadWindow) and when you click on a context menu of NotifyIcon it shows a RadWindow. I've tried several options and none work correctly.

What would be the best approach for this scenario?

 

Thanks

Martin Ivanov
Telerik team
 answered on 30 Mar 2023
1 answer
212 views

Today I tried to put a context menu on a row in a RadGridView that would operate on the row clicked.  I was surprised to find it was not nearly as trivial as I expected.  All the documentation on this is either very old or accomplishing it via code or code-behind.  The "official" demo even has an entry for "Row Context Menu", which sounds tantalizingly close until one looks at the code.  It's certainly not MVVM!

This should be as simple as the following:

<telerik:RadGridView ItemsSource="{Binding Path=MyRecords}">
    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu >
            <telerik:RadMenuItem Header="Do something to this record" Command="{Binding MyRowCommand}" CommandParameter="{Binding ?????}" />
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
	...
</telerik:RadGridView>

The problem is that I can't for the life of me figure out what to pass as the command parameter that will help me identify the row.

Any help would be much appreciated!

Martin Ivanov
Telerik team
 answered on 29 Mar 2023
0 answers
110 views

Hi,

We have switched over from using WPF's built in ContextMenu's to RadContextMenus and we are using Prism Delegated commands.

We have set the "tag" property of the UI element (that has the RadContextMenu attached to it) to an ElementReference to the containing window so that we can then use UIElement.Tag to get back to the Window to then bind to it's PrintCommand.

This all works well, however if we open the ContextMenu from code behind using contMenu.IsOpen = True then the UIElement property is not being set to anything so the command cannot be found.

Is there a different way we should be bindiing the RadContextMenu items to the view commands?

Thanks,

 


<telerik:RadContextMenu  DataContext="{Binding Path=UIElement.Tag, RelativeSource={RelativeSource Self}}" InheritDataContext="False">
   <telerik:RadMenuItem Header="Print" InputGestureText="Ctrl+P"
                                       Command="{Binding PrintCommand}" />
</telerik:RadContextMenu>

Peter
Top achievements
Rank 1
 asked on 16 Mar 2023
1 answer
404 views

I"m following example for context menu in grid view:

https://docs.telerik.com/devtools/wpf/controls/radcontextmenu/how-to/use-radcontextmenu-with-radgridview

Sample grid view has context menu on clicking record: Add/Edit/Delete.

Need advice how to create dynamic context menu on-the-fly based on selected row, using parent-child nodes approach like:

- Notify Option1

      - client 1

      - client 2

      - client <...> (items number is variable based on selected row)

- Notify Option2

      - department1

      - department2

      - department<...> (variable)

- Delete

I'm wonder if it is possible to populate menu items in Click_Row() event instead of static init process this.InitializeRowContextMenuItems();

Another approach would be creating separate dialog inside Click_Row() listing all items for each category "Notify Option1", "Notify Option2". But dynamic menu context looks more clean approach.

 

Martin Ivanov
Telerik team
 answered on 01 Feb 2023
1 answer
328 views

Hello,

I created the ColumnsVisibility attached property to the RadGridView.

When the user clicks the columns' header, I open a context menu that shows all the columns.

Then the user can show/hide the columns by updating the IsVisible property. I am interested to add a button to the left of the first columns header.

The new button will open the Context Menu instead of clicking the Column Header.

I need this functionality because if the users hides all the colums, then there is no header and he will not able to open the menu at all, which means the columns visibilty can't be restored.

I can't attach the property to the RadGridView itself because I have another menu there.

A better solution may be to add this attached property to another style of a control part in the RadGridView template.

I am wondering if there is another control in your template (under the GridViewColumnHeader).

 

At the end I need to open a context menu in the top of the RadGridView but in parallel to open a different ContextMenu when the user clicks and empty space in the rest of the RadGridView (middle/bottom).

Martin Ivanov
Telerik team
 answered on 25 Nov 2022
1 answer
238 views

I have the following ContexMenu:

Which has the following xaml:

<telerik:RadContextMenu.ContextMenu>
  <telerik:RadContextMenu Opened="RadContextMenu_Opened">
    <telerik:RadMenuItem Header="Add" Command="{Binding AddInstance}" IsEnabled="{Binding EpmModelEditModeEnabled}"
                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItem}"
                    Visibility="{Binding EnableEditMode, Converter={StaticResource boolToVisibilityConverter}}"/>
    <telerik:RadMenuItem Header="Rename (F2)" Click="RenameItemMenu_Click" IsEnabled="{Binding EpmModelEditModeEnabled}"
                      Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems, Converter={StaticResource canRenameModelVisibilityConverter}}"/>
    <telerik:RadMenuItem Header="Delete" Command="{Binding DeleteObject}" IsEnabled="{Binding EditModeEnabled}"
                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
    <telerik:RadMenuItem Header="Create Chart Analysis" Command="{Binding CreateChart}" 
                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
    <telerik:RadMenuItem Header="Create Dataset Analysis" Command="{Binding CreateDataset}" 
                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
    <telerik:RadMenuItem x:Name="ColumnsMenu" Header="Columns">
      <telerik:RadMenuItem.ItemTemplate>
        <HierarchicalDataTemplate>
          <MenuItem Header="{Binding Header}" IsCheckable="True" IsChecked="{Binding IsVisible, Mode=TwoWay}"/>
        </HierarchicalDataTemplate>
      </telerik:RadMenuItem.ItemTemplate>
    </telerik:RadMenuItem>
  </telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>

I need to know how do i change the size of the internal selection (in blue) to match the size of the external selection (in yellow), because when i click in the external selection the context menu closes.

At least, if it is not possible to change the size of the internal selection, i need that the context menu does not close when the external selection is clicked (adding StaysOpenOnClick="True" in the MenuItem inside of the <HierarchicalDataTemplate> does not work).

Martin Ivanov
Telerik team
 answered on 10 Nov 2022
0 answers
116 views

I have a radpane include a context menu. when right click over context menu, Radpane is closing and it'is problem for this component.
I used contextmenuopening event but it works before closing and it is not good idea

code is below:




<telerik:RadPaneGroup  Margin="0,0,0,0" >
                    <telerik:RadPane  Name="PaneProcess" CanUserClose="False" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="24" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <telerik:RadWatermarkTextBox x:Name="FilterTree" Grid.Column="0" Grid.Row="0" BorderThickness="1"
					 Margin="0,0,0,0"
					 VerticalAlignment="Top" 
					 MinHeight="24" />
                            <c:TreeViewProcess x:Name="treeViewProcess" IsDragDropEnabled="True" Grid.Row="1" />
                        </Grid>
                    </telerik:RadPane>
                </telerik:RadPaneGroup>

Cemil
Top achievements
Rank 1
Iron
 asked on 09 Jun 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?