AvalonEdit serves as the underlying text editor for SharpDevelop, the free and open source alternative to Visual Studio. The team at SharpDevelop have decoupled a lot of functionalities and have provided the text editor as a separate Nuget Package (available here).
While configurable syntax highlighting and code-completion is a very well-known and advertised feature of AvalonEdit, few are aware that AvalonEdit ships with an out-of-the-box Search panel functionality.
Search panel in action
Image source: AvalonEdit default search panel in ILSpy
After referencing the TextEditor in XAML and in code-behind, simply call the install method on the SearchPanel class to enable integrated search panel functionality.
The above snippet will enable the search panel functionality in the editor when the user presses the “CTRL + F” shortcut.
There is a handy Uninstall method available too to disable the search panel functionality.
Customizing the search panel’s look and feel
While the default UI for the search panel might be sufficient for your application, you might need to style the panel in general, to match the look and feel of your application.
While developing EasyHosts (an open-source hosts file editor), I had to re-style the default look and feel of the search panel to match the theme of the application (shown below). Re-styling the search panel template is a breeze thanks to WPF.
Search panel template
The default search panel template is available on Github.
Note: EasyHosts uses MahApps.Metro UI theme, so brush references below will have to be replaced by your custom theme brushes.