Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be achieved by handling two event: 1) OnMouseDown 2) OnPreviewKeyDown</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Controls; using System.Windows; using System.Windows.Input; namespace WpfApplication2 { public class MultiPartTextBox : TextBox { private string _prefix; private string _content; public string Prefix { get { return _prefix; } set { _prefix = value; Text = _prefix; } } public string Content { get { return _content; } set { _content = value; Text = _prefix + _content; } } public MultiPartTextBox() { _prefix = string.Empty; } protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); this.SelectionStart = _prefix.Length; this.SelectionLength = 0; } //tab In protected override void OnGotFocus(RoutedEventArgs e) { this.SelectionStart = _prefix.Length; this.SelectionLength = 0; base.OnGotFocus(e); } protected override void OnPreviewKeyDown(KeyEventArgs e) { if (e.Key == Key.Back || e.Key == Key.Delete || e.Key==Key.Left) { if (CaretIndex &lt;= _prefix.Length) { e.Handled = true; return; } } base.OnPreviewKeyDown(e); } } } </code></pre> <p>IN Xaml we have to handle it in following way: </p> <pre><code> xmlns:uc="clr-namespace:WpfApplication2" &lt;uc:MultiPartTextBox Height="30" HorizontalAlignment="Left" Margin="80,94,0,0" x:Name="multiPartTxt1" VerticalAlignment="Top" Width="224" Prefix="NON-EDITABLE" CaretIndex="4" &gt; &lt;/uc:MultiPartTextBox&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload