All Projects → Dirkster99 → InplaceEditBoxLib

Dirkster99 / InplaceEditBoxLib

Licence: MIT License
WPF/MVVM control to implement a textbox on top of other elements like TreeViewItem or ListViewItem (use case: perform in place edit on top of a displayed text item)

Programming Languages

C#
18002 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to InplaceEditBoxLib

Edi
Edi - The open source text editor IDE based on AvalonDock and AvalonEdit
Stars: ✭ 220 (+685.71%)
Mutual labels:  wpf, mvvm, ui-components
Celestial.UIToolkit
A custom WPF toolkit which is inspired by a lot of the current design languages, including Microsoft's Fluent Design and Google's Material Design.
Stars: ✭ 32 (+14.29%)
Mutual labels:  modern, wpf, themes
Avalondock
Our own development branch of the well known WPF document docking library
Stars: ✭ 518 (+1750%)
Mutual labels:  light, wpf, mvvm
SimpleDialogs
💬 A simple framework to help displaying dialogs on a WPF app
Stars: ✭ 24 (-14.29%)
Mutual labels:  modern, wpf
ColorPickerLib
A WPF/MVVM implementation of a themeable color picker control.
Stars: ✭ 44 (+57.14%)
Mutual labels:  light, wpf
suru-plus-dark
Suru++ 25 Dark — A full dark cyberpunk, elegant, futuristic and Papirus-like third-party icons theme
Stars: ✭ 55 (+96.43%)
Mutual labels:  modern, dark
Typora Misty Theme
Yet another elegant Typora theme designed with aesthetics in mind.
Stars: ✭ 179 (+539.29%)
Mutual labels:  light, dark
SuggestBoxLib
A WPF Dark/Light AutoComplete TextBox that can easily handle 20.000+ entries.
Stars: ✭ 36 (+28.57%)
Mutual labels:  wpf, textbox
JitPad
On the fly disassemble C# code based on JitDasm
Stars: ✭ 119 (+325%)
Mutual labels:  wpf, dark
Unity-8
Theme mimicking Unity 8's design
Stars: ✭ 22 (-21.43%)
Mutual labels:  modern, themes
serilog-sinks-richtextbox
A Serilog sink that writes log events to a WPF RichTextBox control with colors and theme support
Stars: ✭ 48 (+71.43%)
Mutual labels:  wpf, themes
yiq
Returns white when a color is dark and black when a color is light.
Stars: ✭ 24 (-14.29%)
Mutual labels:  light, dark
NumericUpDownLib
Implements numeric up down WPF controls to edit/display values (byte, integer, short, ushort etc.) with a textbox and optional up/down arrow (repeat) buttons. Value editing is possible by dragging the mouse vertically/horizontally, clicking up/down buttons, using up/down or left right cursor keys, spinning mousewheel on mouseover, or editing th…
Stars: ✭ 68 (+142.86%)
Mutual labels:  light, themes
vscode-theme-gruvbox-minor
Gruvbox theme for Visual Studio Code
Stars: ✭ 17 (-39.29%)
Mutual labels:  light, dark
Themify
👨‍🎨 CSS Themes Made Easy. A robust, opinionated solution to manage themes in your web application
Stars: ✭ 218 (+678.57%)
Mutual labels:  light, themes
hexagonTab
Hexagon bookmarks accented with a chosen colour. Customise the layout, style, background and bookmarks with hexagonTab.
Stars: ✭ 65 (+132.14%)
Mutual labels:  light, dark
stellarized
✦ paint vim with the stars ✦
Stars: ✭ 70 (+150%)
Mutual labels:  light, dark
HandyWinGet
GUI for installing apps through WinGet and Creating Yaml file
Stars: ✭ 305 (+989.29%)
Mutual labels:  wpf, mvvm
OrdersManagementSystem
Project demonstrates usage of Prism composition library, Material design library, SQL Server, Entity Framework in WPF application
Stars: ✭ 29 (+3.57%)
Mutual labels:  wpf, mvvm
Eziam Theme Emacs
A mostly grayscale theme for Emacs, inspired by Tao and Leuven.
Stars: ✭ 74 (+164.29%)
Mutual labels:  light, dark
NuGet Packages Downloads
InplaceEditboxlib NuGet

InplaceEditBoxLib

WPF/MVVM control to implement a textbox on top of other elements like a TreeViewItem or ListViewItem (use case: perform in place edit of a displayed item)




Build status Release NuGet

Net4 NetCore3

Use Case: Edit-In-Place

The edit-in-place text control contained in this project can be used as a base for developing applications where users would like to edit text strings as overlay over the normally displayed string.

The best and well known example of an edit-in-place text control is the textbox overlay that is used for renaming renaming a file or folder in Windows Explorer. The user typically selects an item in a list (listbox, listview, grid) or structure of items (treeview) and renames the item using a textbox overlay (without an additional dialog).

Change of focus (activation of a different window), pressing escapee leads to canceling of the rename process and pressing enter leads to confirmation of the new string.

Editing with Text Overlay

Here is a sequence of screenshots that shows the normal steps when renaming an item with an overlay TextBox control:

Press F2 to start renaming

Type a different sequence of characters

Press enter to confirm the new name

Features

This edit-in-place control in this project can be used in the collection of any ItemsControl (Treeview, ListBox, ListView etc).

Find more details in CodeProject: https://www.codeproject.com/Articles/802385/A-WPF-MVVM-In-Place-Edit-TextBox-Control

Demo in this Repository

The demo program shows how the control can be used in a treeview with:

  • keybinding - Press F2 to rename - Press ESC to cancel renaming

  • Context Menu - Click Rename in context Menu to rename an item

  • Double Click - Double click the text portion to start renaming

Watch this video on youtube https://www.youtube.com/watch?v=iOiveZ214M0&feature=youtu.be

and Handling Errors, such as:

  • Renaming with an invalid character (Press ? in Edit Mode to see a pop-up message)
  • Attempting to name 2 items with the same name (Name 2 items 'a' should invoke a pop-up message on the 2nd items rename)
  • Minimum and Maximum length of a name should between 1 - 254 Characters (naming item with empty string '' should invoke a pop-up message)

Editing text with Text and DisplayText properties

The edit-in-place control has 2 string properties, one is for display (DisplayText) and the other (Text) string represents the value that should be edited.

This setup enables application developers to show more than just a name in each item. Each item can, for example, display a name and a number by using the DisplayText property, while the Text property should contain the string that is to be edit.

The confirmation of editing does not change either of the above dependency properties. The edit-in-place control executes instead the command that is bound to the RenameCommand dependency property to let the viewmodel adjust all relevant strings.

The view invokes the bound RenameCommand and passes the RenameCommandParameter as parameter along.

<EditInPlace:EditBox Text="{Binding Path=DisplayName, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
  DisplayText="{Binding Path=DisplayName,StringFormat={}{0} (File), Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
 ToolTip="{Binding Description, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
  Focusable="True"

  VerticalAlignment="Stretch"
  HorizontalAlignment="Left"
  IsReadOnly="{Binding IsItemReadOnly}"
  RenameCommand="{Binding Path=Data.RenameCommand, Source={StaticResource DataContextProxy}}"
  RenameCommandParameter="{Binding}"
  ToolTipService.ShowOnDisabled="True"
      
  Margin="2,0" />

The actual renaming (changing the data structure and checking for quality issues, such as, minimal length of string, is then performed by the code invoked in the viewmodel. The viewmodel can then choose to show an error notification and refuse the renaming or perform the renaming and close the process (see Demo in SolutionViewModel.cs).

// Do we already know this item?
if (string.IsNullOrEmpty(newName) == true ||
  newName.Length < 1 || newName.Length > 254)
{
    solutionItem.RequestEditMode(RequestEditEvent.StartEditMode);
    solutionItem.ShowNotification("Invalid legth of name",
        "A name must be between 1 and 254 characters long.");
    return;
}

var parent = solutionItem.Parent;

if (parent != null)
{
    // Do we already know this item?
    var existingItem = parent.FindChild(newName);
    if (existingItem != null)
    {
        solutionItem.RequestEditMode(RequestEditEvent.StartEditMode);
        solutionItem.ShowNotification("Item Already Exists",
            "An item with this name exists already. All names must be unique.");
        return;
    }

    parent.RenameChild(solutionItem, newName);

    // This parent selection + sort + child selection
    // scrolls the renamed item into view...
    parent.IsItemSelected = true;
    parent.IsItemExpanded = true;   // Ensure parent is expanded
    parent.SortChildren();
    solutionItem.IsItemSelected = true;
...
}

Initiate Editing Text from the ViewModel

The edit-in-place control expects the viewmodel to implement the InplaceEditBoxLib.Interfaces.IEditBox interface which contains a RequestEdit event. This event can be fired by the viewmodel to start editing of a given item.

Initiate Editing Text from the View

Editing text from the view can be done directly by 'double click' on the text or via command binding on the viewmodel which invokres the RequestEdit event mentioned above.

See demo project with:

  • Rename context menu item or
  • F2 Key binding

Usage of Limited Space

The EditBox in-place overlay control should not exceed the view port area of the parent scrollviewer of the items control. That is, the EditBox should not exceed the visible area of a treeview if it was used within a treeview. This rule ensure that users do not end up typing in an invisible area (off-screen) when typing long string in small areas.

The following sequence of images shows the application behavior when the user enters the string 'The quick fox jumps over the river' in a limited space scenario:

Cancel and Confirm

  • Editing text with the edit-in-place control can be canceled by pressing the 'Esc' key or changing the input focus to another windows or control. The application shows the text as it was before the editing started.

  • Editing text can be confirmed pressing the enter key. The application shows the entered text instead of the text before the editing started.

  • Clicking on the background of the ItemsControl (TreeView, ListView etc) cancels the edit mode (thanks to Alaa Ben Fatma for useful hints).

IsReadOnly property

The edit-in-place control supports a Boolean IsReadonly dependency property to lock individual items from being renamed. Default is false meaning every item is editable unless binding defines somtheing else.

IsEditableOnDoubleClick

Editing the string that is displayed with the edit-in-place control can be triggered with a time 'double click'. This double click can be configured to occur in a certain time frame. There are 2 double dependency properties that can be setup to consume only those double clicks with a time frame that is larger than MinimumClickTime but smaller than MaximumClickTime.

Default values for MinimumClickTime and MaximumClickTime are 300 ms and 700 ms, respectively.

The IsEditableOnDoubleClick boolean dependency property can be setup to dermine whether double clicks are evaluated for editing or not. Default is true.

IsEditing property

The edit-in-place control supports a one way Boolean IsEditing dependency property to enable viewmodels to determine whether an item is currently edited or not. This property cannot be used by the viewmodel to force the view into editable mode (since it is a get only property in the view). Use the RequestEdit event defined in InplaceEditBoxLib.Interfaces.IEditBox to request an edit mode that is initialized by the viewmodel.

Key Filter and Error Handling

The EditBox control contains properties that can be used to define a blacklist of characters that should not be input by the user. See properties:

  • InvalidInputCharacters
  • InvalidInputCharactersMessage
  • InvalidInputCharactersTitle

The control implements a pop-up message element to show hints to the user if he types invalid characters.

Known Limitations

  • Key definitions entered in the in-place textbox cannot be defined through a white-list. The textbox does not support input masks.

  • Restyling TextBox with Hyperlink does not work since a Hyperlink is stored in the InlineCollection of a TextBox. But an InlineCollection cannot be set via dependency property and I cannot seem to work around this with a custom dependency property.

Credits

Theming

Check theming here:

Load Light or Dark brush resources in you resource dictionary to take advantage of existing definitions.

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/InplaceEditBoxLib;component/Themes/DarkBrushes.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/InplaceEditBoxLib;component/Themes/LightBrushes.xaml" />
    </ResourceDictionary.MergedDictionaries>

These definitions do not theme all controls used within this library. You should use a standard theming library, such as:

to also theme standard elements, such as, button and textblock etc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].