C# WPF ribbon:RibbonTextBox vs. TextBox - wpf

After installing Microsoft Ribbon for WPF, I create a WPF Ribbon Application. For textbox, I have choices of "ribbon:RibbonTextBox" or "TextBox" - they seems to work the same to me. Anyone know of the difference between the two?

The RibbonTextBox class implements ICommandSource, which allows it to integrate with the WPF command framework.
For instance, a command can be invoked when the text box has the input focus and the RETURN key is pressed, or the text box can disable itself when its associated command cannot be executed.

Related

WPF - FIND method for TextBox?

After using a Windows Forms RichTextBox, I realized that WPF TextBoxes do not have the .Find Method (as mentioned here). I do not wish to use a WPF RichTextBox as it causes performance issues when I host the element in Windows Forms using HostElement. The WPF TextBox was the way to go in terms of hosting it in Windows Forms
I've heard a lot about Global Search for WPF but I do not wish to implement that feature. Basically what I want is a basic Find method for a WPF textbox. It should consist of a TextBox and a Button. The TextBox is used to enter the string you want to find and the Button should be the command for the Find Method to activate. Each time the user clicks on the Button, the Find method jumps to the next searched result and the next and the next... and act as a loop.
Can someone please help me with this.
I managed to solve the problem by using Regular Expression!

Are native Windows Controls still used in .NET GUIs?

Is the stuff that is displayed when you create a GUI with WinForms or WPF still based on the native controls like Common Controls or any of the system provided Window Classes or is everything that is displayed "custom" drawn by the framework?
Note: I'm not talking about stuff like a file dialog, but GUI that was actually implemented with WinForms or WPF.
And yes, this is purely out of interest.
User HighCore commented:
WPF Uses an "HWND" for the Window objects, but then all other objects
(Controls) inside the Window are WPF objects not related to Win32 in
any way, wheareas AFAIK, winforms uses a separate HWND for each UI
element.
And indeed, using Spy++, we can observe the following when we create a test app with a simple dialog/window and a button on it:
MFC/native:
The app window is a Window (HWND) with the Window Class of #32770 (Dialog) (I used a "Dialog based" app.)
The Button is a separate Window (Class: Button)
Windows Forms:
The app window has the Window Class WindowsForms10.Window.8.app.0.2bf8098_r20_ad1 (oh my)
The Button is a separate Window (Class: WindowsForms10.BUTTON.app.0.2bf8098_r20_ad1)
WPF
There's only one top level Window, although for good measure I added a ComboBox, a ListBox, and a Menu to this window in the UI designer.
The Class of the only Window is: HwndWrapper[WpfApplication1.exe;;9b1aec0f-1b88-419c-8730-858906314cd9]
The Window Class names are actually quite interesting: With the MFC/native one you get the classes known for years and documented on MSDN. With Windows Forms, it does appear that it always uses the same class names. And with WPF it seems the name of a Class of a Window also incorporates the executable/process name.
So apparently MS thinks that using more than one Window per window isn't necessary anymore. I think I need to open a second question for that.
Windows Forms uses native controls for some UI elements. WPF draws everything on its own.

How to execute a command and change focus after a keypress in a WPF app

I have a WPF app that uses MVVM Light and I wish to both execute a command on the view model and change the keyboard focus to a specific control when the user presses ALT+SHIFT+C.
Is it possible to achieve this in an elegant way?
It depends on how the shortcut key is created (if it's like Visual Studio or more like Windows - it means if you have to hold only ALT or all the keys).
But whatever the logic, You will have to first bind an Event to a Command (it might be the event keydown of one of your controls).
In MVVM Light, you will have to use Interaction.Triggers with EventToCommand (there's a lot ot explanations on google and SO)
The logic would be put here in you command.
Then a dependecy property as show here could be implemented for getting the focus.

WPF Component in Windows Application

i have created one component in WPF. its working fine with WPF but when i tried to use it in windows application i am getting one issue.
i have one textbox in that control so in when the control hosted in windows applicaion and i try to type something in that textbox its not working.
i tried to put some messageboxes in "KeyPreview", "KeyDown" and "Textxchanged" events any of these events have not been fired.
so is there any limitation for WPF usercontrols usage in windows application??
one more thing i have used Dispatcher timer in the usercontrol.
This MSDN walkthrough shows how to use a WPF user control in Windows Forms. It may help you in your query.
http://msdn.microsoft.com/en-us/library/ms745781.aspx

Excel & WPF modal form

I've got this situation. (.net 3.5)
A Winform application that with OleAutomation and Office Interop create an excel, a toolbar and handlers for buttons in the toolbar.
Now we've got some functionality that shows the user modal windows (winform 2.0) with the method:
form.ShowDialog(new ExcelHwndWrapper(objExcelApplication.HWND))
And the "owner" of the modal form is set to the "excel" window.
Now I would like to create some WPF Window instead of Winforms due to layout requirements for new functionalities.
Is there any way to Show a WPF ModalDialog "over" excel Window ?
I found something for showing a WPF ModalDialog "over" a winform, but nothing over excel.
Thanks.
When using VSTO and Office 2007, I've had trouble using WPF Windows as modal dialogues. What I found that worked much better was creating a Winforms Form and putting an ElementHost control inside it, then putting my WPF content inside that.
When I used WPF Windows without the Winforms wrapper I ran into trouble with properly capturing keyboard input, among other things.
As long as you make the ElementHost stretch to fill the entire dialogue it'll look like you have a WPF Window.

Resources