I want to add a custom menu item to the menu that appears when a user selects some text and right clicks. I searched a lot but did not get any answer. Maybe I did not put in the right keyword.
Is it possible to do this?
If this is possible, I want to do this for all applications in windows whenever the user selects text. Is there a universal way to do it or will have to write code specific to the application?
I am using C#.
I don't think you can do that universally in all windows apps. But it is certainly possible to do in your own app using a popup menu.
I've also tried a way to add an item to the standard ContextMenu and failed. From my point of view, the only solution is to set the TextBox's ContextMenuStrip property to an instance of the ContextMenuStrip class and implement both standard and your custom menu items. It is easy to mimic standard operation, since the TextBox class provides all required methods: Cut, Copy, Paste, SelectAll.
The universal way is basically writing a "custom shell extension".
There is an article on CodeProject about how to do this.
http://www.codeproject.com/Articles/174369/How-to-Write-Windows-Shell-Extension-with-NET-Lang
The other way to do this is to build this into your application. For example you might have a text editor and you'll want to highlight a word and get a definition for that word. To do this you'll need to implement a context menu.
The VERY BASIC concept is detailed over on CodeReview.StackExchange.
https://codereview.stackexchange.com/questions/3983/c-programatically-creating-context-menu
Related
Can anyone explain what the ProofingMenuFlyout is for in WinUI 3 on a TextBox?
The documentation for it is bare with no example on how to use it.
What I'm actually trying to do is create a popup menu much like the auto suggestion popup in the Visual Studio text editor that gives hints on methods etc. I.e. the one you can open with Ctrl+Space. I want this functionality inside a TextBox as a helper for when certain initial letters are written.
My initial though was to use some dynamic flyout that is opened from a TextChanged callback when a keyword is detected. Then I found this ProofingMenuFlyout that is rather undocumented and I can't figure out how to use, or what it is for.
Am I on the right track with using a menu flyout or should I consider some other way of doing it?
Can anyone explain what the ProofingMenuFlyout is for in WinUI 3 on a TextBox?
It is for spell checking.
I'm trying to add a Windows Shell shortcut (right click context menu item) so anywhere in Windows, when I have text selected this item will appear. I cannot find the Registry item to alter/add or what to put there to get this to occur.
The selected text needs to also be passed to my application as an argument some how. I will be selecting some ID numbers, then manipulating those in the project.
Any assistance is greatly appreciated.
As far as I know, there is no way to create the shell extension which will allow you to inject into the any textbox's context menu.
The most you can do is to hook up the window creating API, filter out everything except context menu creation (WPF windows go down) and then do whatever you want to.
I'm programming an application in WPF using the Ribbon menu, part of the requirements for the application is that I need a commands tab, but this tab should be visible at all times and depending on the active document I would enable/disable the appropriate commands.
My question is, does anyone know a way to split the ribbon menu so that the commands tab is always visible on the right side of the menu?
I'm sure there's an easy answer for this, I just haven't found it yet.
Thanks & Regards!
It's not within the functionality of the ribbon. Why not build a grid with 2 columns, and have the ribbon in the left pane and the custom control on the right? Then you can just style the custom control to match the ribbon.
You can get the source code for the ribbon from CodePlex so you would be able to get the exact style.
It might not be what you wanted to hear, but I think it would be ideal.
Is there a standard .NET control for what I call "a two pane picker", or do I have to code it by hand?
Two pane picker:
The left pane has a list of items.
The user can pick items from the left pane to put them in the right pane using buttons between the two panes.
Picked items in the right pane can be reordered with buttons.
An example of the "two pane picker" can be found by right clicking the Quick Access toolbar in Word 2007 and clicking "Customize Quick Access Toolbar..."
Note: If applicable, VB.NET answers preferred, but C# answers are acceptable too.
There's no standard control for that. Sounds like an excellent case for a custom user/composite control.
There are no .NET Framework controls which create the functionality you describe, however it is fairly easy to implement. Here's some examples I was able to find (not tested):
https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1253&lngWId=10
http://www.dotnetspider.com/resources/18324-Content-Transfer-between-Two-listboxes.aspx
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2082caa0-5ece-4ad8-8077-8c7170fa6f9f
There is no standard picker. You have to build it yourself or find a third party control.
I don't know of anything like that, but its trivial to implement with two ListBoxes and some buttons. When 'Add' is clicked, do .Remove with the item at the selectedIndex from the left and .Add it to the ListBox on the right.
All in WPF:
Developing a wizard application, user has to answer a number of simple questions before brought to the main app. The main app is then prefilled with the information obtained from the wizard.
I started with a Window which I then planned to add usercontrols to. The main window would have the user control in the first row, then Next and Previous buttons to control moving between the controls in the second row. This way I could easily control the logic to switch between screens like:
WizardControl1.IsVisible = false;
WizardControl2.IsVisible = true;
But for some reason, user controls do not have setter for IsVisible. Hurray.
So then I thought I would just use seperate windows for each section of the wizard. The problem with this approach is that now when stepping between, the window opens in random positions, and by steppign through the wizard with next, the next window pops up randomly which is really distracting and frustrating.
So how can I develop a wizard properly? I don't get why this is so hard...not exactly rocket science... replacing text and controls and storing input after pressing next/previous!
Thanks
Check this link:
http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx
This is the article about building wizard in WPF by Josh Smith, it's seems to be nice pattern.
I found it's helpful for me, hope you'll too.
There is also an open source Avalon Wizard control on codeplex.
I'd probably aproach this using data binding and template selectors. Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes.
The WizardData class can expose properties defining the correct info on the forms, and display a control for the main page that uses a template selector to determine the proper control to display based on the actual type of the particular wizard page.
It sounds like more work than it is, really. It also gives you the benefit of good separation between code and UI (all "work" is done by the WizardData and WizardPage classes), and the ability to test logic independent of the UI.
It's also a very WPF/MVVM way of approaching the problem.
I recognize this does not directly address your question, but I thought I'd mention it as a possible alternative. I've used Actipro's Wizard control with pretty good results, and when I have needed support, they have been very responsive. I am not affiliated with them in any way; I just like not having to write the plumbing to manage a wizard.
The property is called "Visibility".
I find that I do better when I dynamically add and removing controls rather than hide them.
I was looking for a Wizard solution too. I have the need to stick with stock WPF components so I implemented the wizard using a standard form and a tab control.
I only hide the tabs at runtime so there available in the IDE. At runtime just use Back, Next, Finish... to navigate thru the tab items
works good