From 4a64b707935dd7fd237e8a993cacaf84e043fd9f Mon Sep 17 00:00:00 2001 From: Karthick-Arjunan Date: Fri, 28 Nov 2025 12:14:10 +0530 Subject: [PATCH 1/2] 993580 - Added sample --- ContextMenu/App.config | 6 + ContextMenu/App.xaml | 9 ++ ContextMenu/App.xaml.cs | 17 +++ ContextMenu/ContextMenu.csproj | 109 +++++++++++++++ ContextMenu/ContextMenu.sln | 25 ++++ ContextMenu/MainWindow.xaml | 134 +++++++++++++++++++ ContextMenu/MainWindow.xaml.cs | 28 ++++ ContextMenu/Properties/AssemblyInfo.cs | 55 ++++++++ ContextMenu/Properties/Resources.Designer.cs | 63 +++++++++ ContextMenu/Properties/Resources.resx | 117 ++++++++++++++++ ContextMenu/Properties/Settings.Designer.cs | 26 ++++ ContextMenu/Properties/Settings.settings | 7 + ContextMenu/ViewModel/ViewModel.cs | 57 ++++++++ 13 files changed, 653 insertions(+) create mode 100644 ContextMenu/App.config create mode 100644 ContextMenu/App.xaml create mode 100644 ContextMenu/App.xaml.cs create mode 100644 ContextMenu/ContextMenu.csproj create mode 100644 ContextMenu/ContextMenu.sln create mode 100644 ContextMenu/MainWindow.xaml create mode 100644 ContextMenu/MainWindow.xaml.cs create mode 100644 ContextMenu/Properties/AssemblyInfo.cs create mode 100644 ContextMenu/Properties/Resources.Designer.cs create mode 100644 ContextMenu/Properties/Resources.resx create mode 100644 ContextMenu/Properties/Settings.Designer.cs create mode 100644 ContextMenu/Properties/Settings.settings create mode 100644 ContextMenu/ViewModel/ViewModel.cs diff --git a/ContextMenu/App.config b/ContextMenu/App.config new file mode 100644 index 0000000..8d23437 --- /dev/null +++ b/ContextMenu/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ContextMenu/App.xaml b/ContextMenu/App.xaml new file mode 100644 index 0000000..1d78139 --- /dev/null +++ b/ContextMenu/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ContextMenu/App.xaml.cs b/ContextMenu/App.xaml.cs new file mode 100644 index 0000000..c9d0cc7 --- /dev/null +++ b/ContextMenu/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ContextMenu +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/ContextMenu/ContextMenu.csproj b/ContextMenu/ContextMenu.csproj new file mode 100644 index 0000000..034e0bb --- /dev/null +++ b/ContextMenu/ContextMenu.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {85F1D866-8D0B-432D-B3E8-97D80AD1D292} + WinExe + ContextMenu + ContextMenu + v4.6.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll + + + + + + + + packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/ContextMenu/ContextMenu.sln b/ContextMenu/ContextMenu.sln new file mode 100644 index 0000000..408af9b --- /dev/null +++ b/ContextMenu/ContextMenu.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29911.84 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContextMenu", "ContextMenu.csproj", "{85F1D866-8D0B-432D-B3E8-97D80AD1D292}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85F1D866-8D0B-432D-B3E8-97D80AD1D292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85F1D866-8D0B-432D-B3E8-97D80AD1D292}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85F1D866-8D0B-432D-B3E8-97D80AD1D292}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85F1D866-8D0B-432D-B3E8-97D80AD1D292}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C9EA5AC1-69CA-43E5-B39D-7BFA485684D7} + EndGlobalSection +EndGlobal diff --git a/ContextMenu/MainWindow.xaml b/ContextMenu/MainWindow.xaml new file mode 100644 index 0000000..61a3b93 --- /dev/null +++ b/ContextMenu/MainWindow.xaml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Visible + Collapsed + + + + + + + + + + \ No newline at end of file diff --git a/ContextMenu/MainWindow.xaml.cs b/ContextMenu/MainWindow.xaml.cs new file mode 100644 index 0000000..482817e --- /dev/null +++ b/ContextMenu/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ContextMenu +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/ContextMenu/Properties/AssemblyInfo.cs b/ContextMenu/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..750612d --- /dev/null +++ b/ContextMenu/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ContextMenu")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ContextMenu")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ContextMenu/Properties/Resources.Designer.cs b/ContextMenu/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c60f26e --- /dev/null +++ b/ContextMenu/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ContextMenu.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ContextMenu.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ContextMenu/Properties/Resources.resx b/ContextMenu/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ContextMenu/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ContextMenu/Properties/Settings.Designer.cs b/ContextMenu/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f643ecb --- /dev/null +++ b/ContextMenu/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ContextMenu.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/ContextMenu/Properties/Settings.settings b/ContextMenu/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/ContextMenu/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ContextMenu/ViewModel/ViewModel.cs b/ContextMenu/ViewModel/ViewModel.cs new file mode 100644 index 0000000..cea69dc --- /dev/null +++ b/ContextMenu/ViewModel/ViewModel.cs @@ -0,0 +1,57 @@ +using Syncfusion.Windows.Shared; +using System.Windows; + +namespace ContextMenu +{ + public class ViewModel : NotificationObject + { + private bool showTabItemContextMenu = true; + private bool showTabListContextMenu =true; + private bool isCustomTabItemContextMenuEnabled=true; + private Visibility defaultContextMenuItemVisibility= Visibility.Visible; + + public Visibility DefaultContextMenuItemVisibility + { + get { return defaultContextMenuItemVisibility; } + set + { + defaultContextMenuItemVisibility = value; + this.RaisePropertyChanged(nameof(DefaultContextMenuItemVisibility)); + } + } + + public bool ShowTabItemContextMenu + { + get { return showTabItemContextMenu; } + set + { + showTabItemContextMenu = value; + this.RaisePropertyChanged(nameof(ShowTabItemContextMenu)); + } + } + + public bool ShowTabListContextMenu + { + get { return showTabListContextMenu; } + set + { + showTabListContextMenu = value; + this.RaisePropertyChanged(nameof(ShowTabListContextMenu)); + } + } + + public bool IsCustomTabItemContextMenuEnabled + { + get { return isCustomTabItemContextMenuEnabled; } + set + { + isCustomTabItemContextMenuEnabled = value; + this.RaisePropertyChanged(nameof(IsCustomTabItemContextMenuEnabled)); + } + } + + public ViewModel() + { + } + } +} From 5c7368a2bbdef97e78a0a76bbb9853dd804af186 Mon Sep 17 00:00:00 2001 From: Karthick-Arjunan Date: Fri, 28 Nov 2025 12:19:03 +0530 Subject: [PATCH 2/2] 993580 - Updated the README.md file --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f44a95..a4416fe 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,49 @@ # wpf-tabcontrol-contextmenu -This repository contains the sample which shows set context menu for tabitem of Syncfusion TabControl for WPF. + +This sample demonstrates how to configure **context menus** for tab items in **Syncfusion TabControlExt** in a WPF application. The `TabControlExt` control provides built-in context menu support and allows customization of menu items for individual tabs. + +## Features in This Sample +- **Built-in Context Menu**: Enable or disable default context menu options for tab items and tab list. +- **Custom Context Menu Items**: Add custom menu items and sub-items to tab headers. +- **MVVM Support**: Bind context menu visibility and customization options to properties in the `ViewModel`. +- **Nested Menu Items**: Create hierarchical context menus with multiple levels. + +## Key Properties Used +- **ShowTabItemContextMenu**: Shows or hides the context menu for tab items. +- **ShowTabListContextMenu**: Shows or hides the context menu for the tab list. +- **IsCustomTabItemContextMenuEnabled**: Enables custom context menu items for tab items. +- **DefaultContextMenuItemVisibility**: Controls visibility of default context menu items (Visible or Collapsed). + +## XAML Overview +```xml + + + + + + + + + + + + + + + + + + +``` + +## How It Works +1. The `ViewModel` exposes properties like `ShowTabItemContextMenu`, `ShowTabListContextMenu`, and `IsCustomTabItemContextMenuEnabled`. +2. These properties are bound to the `TabControlExt` to dynamically control context menu behavior. +3. Custom context menu items are defined inside each `TabItemExt` using `CustomMenuItem` elements. + +## Documentation +For more details, refer to the official Syncfusion documentation: +[TabControl ContextMenu](https://help.syncfusion.com/wpf/tabcontrol/contextmenu)