DevToys logo DevToys
  • Home
  • Blog
  • Documentation
  • Download
Search Results for

    Show / Hide Table of Contents

    Singleline Text Input

    You can display a text input with associated command bar using the SingleLineTextInput() static method, which produces a IUISingleLineTextInput.

    Sample

    using DevToys.Api;
    using System.ComponentModel.Composition;
    using static DevToys.Api.GUI;
    
    namespace MyProject;
    
    [Export(typeof(IGuiTool))]
    [Name("My Tool")]
    [ToolDisplayInformation(
        IconFontName = "FluentSystemIcons",
        IconGlyph = '\uE670',
        ResourceManagerAssemblyIdentifier = nameof(MyResourceAssemblyIdentifier),
        ResourceManagerBaseName = "MyProject.Strings",
        ShortDisplayTitleResourceName = nameof(Strings.ShortDisplayTitle),
        DescriptionResourceName = nameof(Strings.Description),
        GroupName = "My Group")]
    internal sealed class MyGuiTool : IGuiTool
    {
        public UIToolView View
            => new UIToolView(
                Stack()
                    .Vertical()
                    .WithChildren(
    
                        SingleLineTextInput()
                            .Title("Title")
                            .OnTextChanged(OnSingleLineTextInputTextChanged),
    
                        SingleLineTextInput()
                            .Title("Read only")
                            .ReadOnly(),
    
                        SingleLineTextInput()
                            .Title("No command bar")
                            .HideCommandBar(),
    
                        SingleLineTextInput()
                            .Title("Copy command even when editable")
                            .CanCopyWhenEditable(),
    
                        SingleLineTextInput()
                            .Title("Extra command")
                            .CommandBarExtraContent(
                                Button()
                                    .Text("Click me!")
                                    .AccentAppearance())));
    
        public void OnDataReceived(string dataTypeName, object? parsedData)
        {
            // Handle Smart Detection.
        }
    
        private void OnSingleLineTextInputTextChanged(string text)
        {
        }
    }
    

    The code above produces the following UI:

    DevToys - My Tool - Singleline Text Input

    In this article
    DevToys logo © 2024 DevToys