🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Parsed/Databound Placeholder text
This page was created by PageReplicator on 2025-09-01. Last edited by PageReplicator on 2025-09-01.

Template:Notice



Placeholder text is the text shown as a hint to the User while the control is empty. As soon as the User enters a value, the placeholder text is not shown.

<a href="/File:Input_control_with_placeholder.png" class="image" data-bs-title="File:Input_control_with_placeholder.png" data-bs-filetimestamp="20210825221321"><img alt="Input control with placeholder.png" src="/images/thumb/9/9e/Input_control_with_placeholder.png/300px-Input_control_with_placeholder.png" decoding="async" width="300" height="50" class="thumbimage" srcset="/images/thumb/9/9e/Input_control_with_placeholder.png/450px-Input_control_with_placeholder.png 1.5x, /images/thumb/9/9e/Input_control_with_placeholder.png/600px-Input_control_with_placeholder.png 2x" /></a>
<a href="/File:Input_control_with_placeholder.png" class="internal" title="Enlarge"></a>

The old way was a <a href="/Documentation:TaggedValues" title="Documentation:TaggedValues" data-bs-title="Documentation:TaggedValues">taggedvalue</a> "Placeholder" along with the desired text to show "Enter a search string..." - this is deprecated.

The new way is to name an additional column with postfix _Placeholder in its name. The result of the expression will be used as a placeholder text.

This has been available in Turnkey since early 2022.

In WPF, you need to add code, since the out-of-the-box controls of WPF do not support placeholder texts.

If you use the excellent MaterialDesign (<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="http://materialdesigninxaml.net/">MaterialDesignThemes by James Willock)</a> package, this code will get the effect:

      _wecpof = new WECPOFTabBased();
      ...
      _wecpof.OnAddWindow += (s, e) =>
      {
        e.Win.ViewModelUC.OnViewModelColumnPlacementDone += (s2, e2) =>
        {
          if (e2.Ctrl is System.Windows.Controls.TextBox || e2.Ctrl is System.Windows.Controls.ComboBox || e2.Ctrl is System.Windows.Controls.DatePicker)
          {
            var val = e2.Vcol.TaggedValueLocalAndModelInfo("Placeholder");
            if (!string.IsNullOrEmpty(val))
              MaterialDesignThemes.Wpf.HintAssist.SetHint(e2.Ctrl, val);
            var dataForPlaceholder = e2.Vcol.ViewModelClass.ColumnFromName(e2.Vcol.RuntimeName + "_Placeholder");
            if (dataForPlaceholder != null)
            {
              if (e2.Ctrl is FrameworkElement)
              {
                var b = new System.Windows.Data.Binding(dataForPlaceholder.RuntimeName) { Source = e2.Vcol.ViewModelClass.BindingSource, Mode = System.Windows.Data.BindingMode.OneWay /*, Converter = new Eco.Xaml.PassthroughDebugConverter() */ };
                (e2.Ctrl as FrameworkElement).SetBinding(MaterialDesignThemes.Wpf.HintAssist.HintProperty, b);
              }
            }
          }
        };