Your requirement is not clear but lets break it down
First Approach
By default text box shows first name name when some one clicks on it, then it will show full name(first name, middle name or last name) and again if clicks it will show the first name
<TextBox x:Name="textBox" Text="{Binding FirstName}" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus"/>
Code behind
public partial class MainWindow : Window
{
private MainViewModel _viewModel;
public MainWindow()
{
InitializeComponent();
_viewModel = new MainViewModel();
DataContext = _viewModel;
}
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
if (!_viewModel.IsFullNameVisible)
{
_viewModel.IsFullNameVisible = true;
_viewModel.RefreshDisplayedName();
}
}
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
if (_viewModel.IsFullNameVisible)
{
_viewModel.IsFullNameVisible = false;
_viewModel.RefreshDisplayedName();
}
}
}
View Model
public class MainViewModel : INotifyPropertyChanged
{
private string _firstName;
private string _lastName;
private bool _isFullNameVisible;
public string FirstName
{
get { return _firstName; }
set
{
if (_firstName != value)
{
_firstName = value;
OnPropertyChanged(nameof(FirstName));
RefreshDisplayedName();
}
}
}
public string LastName
{
get { return _lastName; }
set
{
if (_lastName != value)
{
_lastName = value;
OnPropertyChanged(nameof(LastName));
RefreshDisplayedName();
}
}
}
public bool IsFullNameVisible
{
get { return _isFullNameVisible; }
set
{
if (_isFullNameVisible != value)
{
_isFullNameVisible = value;
OnPropertyChanged(nameof(IsFullNameVisible));
}
}
}
public string DisplayedName
{
get { return _isFullNameVisible ? $"{_firstName} {_lastName}" : _firstName; }
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void RefreshDisplayedName()
{
OnPropertyChanged(nameof(DisplayedName));
}
}
Second Approach
Create a three textbox, default make the middle name & last name hidden and when some once click first text box change the visibility of middle name and last name text box you can reuse the above code