WPF - partially uneditable textbox
c#, wpf, xaml
Solution
You could use three TextBox controls within a StackPanel:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
<TextBox BorderThickness="1,1,0,1"/>
<TextBox BorderThickness="0,1,0,1"
Text="Chunk 2" IsReadOnly="True"
IsTabStop="False" />
<TextBox BorderThickness="0,1,1,1"/>
</StackPanel>
</Grid>
The result looks like this:
EDIT: You should be able to jump from the first TextBox to the last using the Tab key.
Problem
Is there a way to add a fixed piece of text (TextBlock or Label) inside WPF's TextBox? Such that; user can write text around it in the control, but can't delete or edit it? I am looking for the reciprocal of this question, that is: ``` <TextBox> "Chunk #1: This part of text is editable" "Chunk #2: This piece is not editable" "Chunk #3: This text is editable" </TextBox> ``` (Note: these are the imaginary chucks there for elaboration, its all continuation of one block of text; which may be multi-line with line-breaks). where `Chunk #2` should move accordingly, as user edits `Chunk #1` and `#3`.