This question is locked. New answers and comments are not allowed.
| <telerikNavigation:RadMenu ClickToOpen="True" VerticalAlignment="Top" BorderThickness="0" Background="Transparent" telerik:StyleManager.Theme="{StaticResource Theme}" > |
| <telerikNavigation:RadMenuItem Click="RadMenuItem_Click" VerticalAlignment="Top" BorderThickness="0" Background="Transparent" StaysOpenOnClick="False" > |
| <telerikNavigation:RadMenuItem.Icon > |
| <Image Source="../../Images/downArrowGray.png"/> |
| </telerikNavigation:RadMenuItem.Icon> |
| <telerikNavigation:RadMenuItem Name="rmiEdit" Header="Edit" Click="EditItem_Click" BorderThickness="0"></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiDelete" Header="Delete" Command="{Binding Path=ParentCalendarViewModel.DeleteCalendarCommand}" Click="DeleteItem_Click" BorderThickness="0"></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiInactivate" Header="Inactivate" BorderThickness="0" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiAddCalendarDate" BorderThickness="0" Command="{Binding Path=ParentCalendarViewModel.AddNewCalendarDateRow}" Header="Add a Calendar Date" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiAddNote" BorderThickness="0" Header="Add a Note" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiViewHistory" BorderThickness="0" Header="View History" ></telerikNavigation:RadMenuItem> |
| </telerikNavigation:RadMenuItem> |
| </telerikNavigation:RadMenu> |
The above is my RadMenuItem, how can I close the submenu programmatically from cs code file.
when the user clicks on the RadMenuItem , the submenu opens, but on some conditions how can I close it from cs file code. and I have access to the RadMenuItem object.
The following is the code attached with the scenario -
| <UserControl x:Class="ContextMenu_ShowFromCode.Page" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| xmlns:core="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
| xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
| xmlns:nav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"> |
| <Grid x:Name="LayoutRoot" Background="White"> |
| <StackPanel Orientation="Vertical"> |
| <telerikNavigation:RadMenu ClickToOpen="True" VerticalAlignment="Top" BorderThickness="0" Background="Transparent" > |
| <telerikNavigation:RadMenuItem Click="RadMenuItem_Click" VerticalAlignment="Top" BorderThickness="0" Background="Transparent" > |
| <telerikNavigation:RadMenuItem.Icon > |
| <Image Source="../../Images/downArrowGray.png"/> |
| </telerikNavigation:RadMenuItem.Icon> |
| <telerikNavigation:RadMenuItem Name="rmiEdit" Header="Edit" Click="EditItem_Click" BorderThickness="0"></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiDelete" Header="Delete" BorderThickness="0"></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiInactivate" Header="Inactivate" BorderThickness="0" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiAddCalendarDate" BorderThickness="0" Header="Add a Calendar Date" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiAddNote" BorderThickness="0" Header="Add a Note" ></telerikNavigation:RadMenuItem> |
| <telerikNavigation:RadMenuItem Name="rmiViewHistory" BorderThickness="0" Header="View History" ></telerikNavigation:RadMenuItem> |
| </telerikNavigation:RadMenuItem> |
| </telerikNavigation:RadMenu> |
| <TextBox Name="txtbxTemp" LostFocus="TextBox_LostFocus" ></TextBox> |
| </StackPanel> |
| </Grid> |
| </UserControl> |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Net; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Animation; |
| using System.Windows.Shapes; |
| using Telerik.Windows.Controls; |
| namespace ContextMenu_ShowFromCode |
| { |
| public partial class Page : UserControl |
| { |
| public Page() |
| { |
| InitializeComponent(); |
| } |
| private void RadMenuItem_Click(object sender, RoutedEventArgs e) |
| { |
| } |
| private void TextBox_LostFocus(object sender, RoutedEventArgs e) |
| { |
| // I want to hide the already opened submenu here. |
| // And I have the RadMenuItem object available. |
| } |
| } |
| } |
In the above text box the user enters some value and hits the RadMenuItem, the TextBox_LostFocus is fired and the submenu is also opened. But I don't want the RadMenuItem's submenu to open up.