Telerik Forums
UI for WPF Forum
1 answer
17 views

Hello

Question  about ===> public ControlTemplate SeparatorTemplateKey {get;set}

 

I don't know how to use (public ControlTemplate SeparatorTemplateKey {get;set}

). Please teach me.
I don't know how to use (public ControlTemplate SeparatorTemplateKey {get;set}

), so it's very difficult for me.

 

 

<Window.Resources
        <ControlTemplate x:Key="SeparatorTemplate" TargetType="telerik:RadMenuItem"
            <Grid HorizontalAlignment="Stretch">                 
                    <Rectangle Fill="Red" Height="20" Width="1" VerticalAlignment="Stretch"/> 
                    <Rectangle Fill="Blue" Height="20" Width="1" VerticalAlignment="Stretch"/>               
            </Grid
        </ControlTemplate>   
</Window.Resources>     
    
<Grid x:Name="LayoutRoot" Background="White"
        <telerik:RadMenu x:Name="radMenu" ClickToOpen="False" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="8,8,0,0"
            <telerik:RadMenuItem Header="File"/> 
            <telerik:RadMenuItem Header="Edit" IsSeparator="True" Template="{StaticResource SeparatorTemplate}" />              
            <telerik:RadMenuItem Header="View" />            
        </telerik:RadMenu

</Grid>

 

 

--------

using System.Windows.Controls;
public override ObservableCollection<MenuItem> GetMenu()
{
    var contextmenuitem = new ObservableCollection<MenuItem>(); 
    var eRNode = crateMenuItem("Report");
    eRNode.Items.Add(createMenuItem("Sub"));
  
    contextmenuitem.Add(Separate); <===
    ControlTemplate template = new ControlTemplate();
    template.key = "Tamplate";
    contextmenuitem.Add(SeparatorTemplateKey(template)); <===ControlTemplate x:Key="Template" OF XAML.xaml File .... <==I don't know grammar. How do I write code?
    contextmenuitem.Add(eRNode);
}

 

 

 

 

Martin Ivanov
Telerik team
 answered on 28 Apr 2025
1 answer
76 views
Hi , I'm trying to automate the testing of a WPF program by writing code. I can perform actions on the main window of the program, but I can't do it on a different window. I think the reason for this is that it doesn't recognize that window. However, I couldn't find out how to switch to a different window.Can you help me ?. Here's an example of the code I've written:
        [CodedStep(@"Type 'XXX' into ServerNameWatermarkTextbox")]
        public void ConfirmInstalledDate_CodedStep()
        {
            string formattedDate = DateTime.Now.ToString("yyyy-MM-dd");
            ActiveApplication.MainWindow.Find.ByName("serverNameWatermark").User.TypeText("XXX",2);
            ActiveApplication.MainWindow.Find.ByName("usernameWaterMark").User.TypeText("logadmin",2);         
            ActiveApplication.MainWindow.Find.ByName("usernameWaterMark").KeyPress(ArtOfTest.WebAii.Win32.KeyBoard.KeysFromString("Tab"),1,1,1);
            ActiveApplication.MainWindow.Find.ByName("pwdBox").User.TypeText("XXX",2);
            ActiveApplication.MainWindow.Find.ByName<Button>("btnSignIn").User.Click();
            System.Threading.Thread.Sleep(5000);
            ActiveApplication.MainWindow.Find.ByName("imgData").User.Click();
            ActiveApplication.MainWindow.Find.ByTextContent("Status").User.Click(MouseClickType.RightClick);
            ActiveApplication.MainWindow.Find.ByTextContent("Select columns").User.Click();
            ActiveApplication.GetWindow("Select columns");
            ActiveApplication.GetWindow("Select columns").Find.ByName("txtSearch").User.TypeText("Date",2); 
            System.Threading.Thread.Sleep(5000);
            ActiveApplication.GetWindow("Select columns").Find.ByName("txtSearch").User.KeyPress(System.Windows.Forms.Keys.Enter,1);
            ActiveApplication.MainWindow.Find.ByTextContent("^"+formattedDate).User.Click();
            System.Threading.Thread.Sleep(2000);
        }
    }
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 10 May 2024
2 answers
97 views

Please help. I'm trying to get keyboard inputs to work for a RadMenu. Here are the three different ways I'm trying to get working. Just to be clear, NONE work. And yes, there are valid commands backing these. When I try this with Window.InputBindings I can get it to work, but i would like to have the keyboard declaration as near the menu as possible. This shouldn't be this hard, please help.

<telerik:RadMenu Grid.Row="0" NotifyOnHeaderClick="True" VerticalAlignment="Center" Grid.ColumnSpan="3">
			<telerik:RadMenuItem Header="_File">
				<telerik:RadMenuItem Header="_New" InputGestureText="Ctrl+N" Command="{Binding NewCommand}">
					<telerik:RadMenuItem.InputBindings>
						<KeyBinding Gesture="Ctrl+N" Command="{Binding NewCommand}"/>
					</telerik:RadMenuItem.InputBindings>
				</telerik:RadMenuItem>
				<telerik:RadMenuItem Header="_Save" InputGestureText="Ctrl+S" CommandTarget="{Binding SaveCommand, Mode=OneWay}" />
				<telerik:RadMenuItem Header="_Cancel" InputGestureText="ESC"/>
				<telerik:RadMenuItem Header="_Delete" InputGestureText="Ctrl+D" Command="{Binding DeleteCommand}" />
				<telerik:RadMenuSeparatorItem />
				<telerik:RadMenuItem Header="E_xit" InputGestureText="Alt+F4" Command="{Binding FileExitCommand}" />
			</telerik:RadMenuItem>
			<telerik:RadMenuItem Header="_Help">
				<telerik:RadMenuItem Header="_Support" Command="{Binding NavigateToAvantiSupportWebpageCommand}" CommandParameter="https://avantisystems.com/support-portal/"/>
				<telerik:RadMenuSeparatorItem />
				<telerik:RadMenuItem Header="_About" Command="{Binding HelpAboutCommand}"/>
			</telerik:RadMenuItem>
		</telerik:RadMenu>
Peter
Top achievements
Rank 1
Iron
 answered on 15 Feb 2024
1 answer
100 views

Hi,

I currently am using a RadMenuItem to show one particular Icon for example the Whatsapp logo.

When I hover over the RadMenuItem I would like the icon to change to another version (white) which will be more visible due to our RadMenuItem mouse over having a darker background.

The code below is showing the original logo but the IsMouseOver trigger does not appear to be working.

Here is my code:

MainWindow.Xaml

                        <telerik:RadMenuItem Height="30" 
                                             Command="{Binding EmailSupportCommand}"
                                             FontSize="14" IconColumnWidth="30" Header="Email info@.com"
                                             >
                            <telerik:RadMenuItem.Icon>
                                <Image>
                                    <Image.Style>
                                        <Style TargetType="{x:Type Image}">
                                            <Setter Property="Source" Value="..\..\Auxiliary\Resources\64x64\dark\email.png" />
                                            <Style.Triggers>
                                                <DataTrigger Value="True" Binding="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadMenuItem}, Path=IsMouseOver}">
                                                    <Setter Property="Source" Value="..\..\Auxiliary\Resources\64x64\light\email.png" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </telerik:RadMenuItem.Icon>
                        </telerik:RadMenuItem>


Dinko
Telerik team
 answered on 03 Aug 2023
0 answers
116 views

I'm facing an issue with the RadMenu control. I have a requirement where I need to display a menu with collapsible items, and I would like some guidance on how to implement this functionality.

Here's a simplified example of my current XAML code:

<telerik:RadMenu>
    <telerik:RadMenuItem Header="Menu">
        <telerik:RadMenuGroupItem ItemsSource="{Binding Alist}" Header="A"/>
        <telerik:RadMenuGroupItem ItemsSource="{Binding Blist}" Header="B"/>
    </telerik:RadMenuItem>
</telerik:RadMenu>

In this example, I have two RadMenuGroupItems, "A" and "B", each bound to a separate list (Alist and Blist respectively). Currently, the items are displayed in an expanded state by default.

However, I would like to achieve the following behavior:

1. Initially, all the items in the lists should be collapsed, i.e., hidden.

2. Users should be able to expand and collapse the items by clicking on the respective RadMenuGroupItem headers. When the header is clicked, the items should toggle between being expanded (visible) and collapsed (hidden).

Is there a built-in way to achieve this behavior in the RadMenu or RadMenuGroupItem controls? If not, could you please provide some guidance on how I can implement this functionality myself?

I appreciate any assistance or code examples you can provide to help me accomplish this requirement.

Thank you in advance for your help.

Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
 updated question on 18 May 2023
1 answer
104 views

I've tried to combine the Telerik examples 'Dynamic RadMenu' with 'Switching themes at runtime'.
I've realized, that the subitems of the RadMenu do not change the theme (color) correctly.

I think that the ItemContainerStyle don't work correctly.

I've attached an example with two RadMenu.
First is created dynamically the second is static.

In the menu you can switch to different themes.
Please have look to the submenues (file). The color don't change.

I've also realized that also the size of the icons are displayed differently.

Stenly
Telerik team
 answered on 22 Aug 2022
1 answer
119 views

Hi,

I have a RadContextMenu and want to use access keys with it, I've added underscores to headers in my RadMenuItems and functionally it's all working however the characters in the menu aren't underlined, I tried looking into this online but could only seem to find anything on getting them to appear in a RadMenu when using alt which doesn't appear to be an option for the context menu control. It seems like it should be default functionality so I don't know if maybe I'm just missing something obvious.

Thanks for any help

Stenly
Telerik team
 answered on 14 Dec 2021
1 answer
272 views

Hello.

 

I want to make it similar to an image.

I made the design, but binding is the problem.
There is a model, there is a displayname, and there are values.

The dropdown shows the sub item name when selected, and the value uses the value when the button is selected later.

(I know listbox doesn't support this. So I try to use dropdown.)

A parent item may have a value and a child may not. This shouldn't be an option.

The IsSelected function does not exist.

 

How do I put the binding and do it?

<telerik:RadDropDownButton Content="{Binding }">
	<telerik:RadDropDownButton.DropDownContent>
		<telerik:RadContextMenu x:Name="ContextMenu" ItemsSource="{Binding }">
			<telerik:RadMenuItem Header="parent name binding 1">
				<telerik:RadMenuItem Header="child name binding 1.1"/>
				<telerik:RadMenuItem Header="child name binding 1.2"/>
				<telerik:RadMenuItem Header="child name binding 1.3"/>
			</telerik:RadMenuItem>
			<telerik:RadMenuItem Header="parent name binding 2">
				<telerik:RadMenuItem Header="child name binding 2.1"/>
				<telerik:RadMenuItem Header="child name binding 2.2"/>
			</telerik:RadMenuItem>
			<telerik:RadMenuItem Header="parent name binding 3">
				<telerik:RadMenuItem Header="child null"/>
			</telerik:RadMenuItem>
		</telerik:RadContextMenu>
	</telerik:RadDropDownButton.DropDownContent>
</telerik:RadDropDownButton>

 

Thanks.

 

Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
 answered on 28 Jun 2021
1 answer
183 views

I set a global textblock style in app.xaml in order to styling text in dialog:

<Style TargetType="TextBlock" x:Key="{x:Type TextBlock}">
<Setter Property="Width" Value="100"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="t:StyleManager.Theme" Value="{StaticResource GlobalTheme}"/>
</Style>

But when I run the application I saw that the width property affect the space left for the menu item in toolbar:

This is the appearance without textblock style:



How can I use the style without change the Menu?
Thank you
Luigi

Martin Ivanov
Telerik team
 answered on 04 May 2021
15 answers
173 views

Hi,

If a button is placed in a RadMenu that causes navigation (in a Frame/Page setup), then the button is not getting focus and hence any Bindings that are present where the focus is are not executed before navigation takes place.  I see https://www.telerik.com/forums/radmenu-problem-404186d89499 and https://www.telerik.com/forums/i-think-i-found-a-nasty-bug which look like the same problem.  Is there any solution for this problem aside from not using RadMenu that will work for the focus being in any control?  I note that in Silverlight RadMenu does not have this problem. 

Vladimir Stoyanov
Telerik team
 answered on 22 Apr 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?