public MessageRequestView()
        {
            InitializeComponent();

            _formattedTextMarkerService = new AvalonEditTextMarkerService(FormattedTextEditor);

            var textView = FormattedTextEditor.TextArea.TextView;

            textView.BackgroundRenderers.Add(_formattedTextMarkerService);
            textView.LineTransformers.Add(_formattedTextMarkerService);
            textView.Services.AddService(typeof(AvalonEditTextMarkerService), _formattedTextMarkerService);

            this.WhenActivated(disposables =>
            {
                this.WhenAnyValue(v => v.ViewModel)
                .Subscribe(NewViewModel =>
                {
                    _viewModelDisposables?.Dispose();
                    _viewModelDisposables = new CompositeDisposable();

                    _formattedTextMarkerService.Clear();

                    if (NewViewModel == null)
                    {
                        return;
                    }

                    this.Bind(NewViewModel, vm => vm.MessageId, v => v.MessageIdTextBox.Text)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.Token, v => v.MessageToken.Text,
                              MessageToken.Events().LostFocus,
                              x => _hextoAsciiConverter.Convert(x, typeof(string), 8, CultureInfo.CurrentCulture),
                              x => _hextoAsciiConverter.ConvertBack(x, typeof(byte[]), 8, CultureInfo.CurrentCulture))
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.AutoIncrement, v => v.IncrementMessageIDCheckBox.IsChecked)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.Code, v => v.MessageCodeComboBox.SelectedValue)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.ContentFormat, v => v.ContentTypeComboBox.SelectedValue)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.Options, v => v.OptionsList.Options)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.Payload, v => v.MessageTextBox.Text)
                    .DisposeWith(_viewModelDisposables);

                    MessageTextBox.Events()
                    .LostKeyboardFocus
                    .Select(_ => MessageViewModel.UpdatePayloadSource.Text)
                    .InvokeCommand(NewViewModel.UpdatePayloads)
                    .DisposeWith(_viewModelDisposables);

                    this.WhenAnyValue(v => v.DisplayUnicode.IsSelected)
                    .InvokeCommand(NewViewModel, vm => vm.EscapePayload)
                    .DisposeWith(_viewModelDisposables);

                    this.Bind(NewViewModel, vm => vm.FormattedPayload, v => v.FormattedTextEditor.Document.Text)
                    .DisposeWith(_viewModelDisposables);

                    FormattedTextEditor.Events()
                    .LostKeyboardFocus
                    .Select(_ => MessageViewModel.UpdatePayloadSource.Formatted)
                    .InvokeCommand(NewViewModel.UpdatePayloads)
                    .DisposeWith(_viewModelDisposables);

                    NewViewModel.WhenAnyValue(vm => vm.ContentFormat)
                    .Select(cf => CoapFormatHighlightingManager.Default.GetDefinition(cf))
                    .Subscribe(d => FormattedTextEditor.SyntaxHighlighting = d)
                    .DisposeWith(_viewModelDisposables);

                    var formattedTextMarkers = NewViewModel.FormattedPayloadErrors.CreateDerivedCollection(ex =>
                    {
                        var marker         = AvalonEditTextMarkerService.TextMarker.Create(FormattedTextEditor, ex.Offset, ex.Line);
                        marker.ToolTip     = ex.Message;
                        marker.MarkerColor = ((TryFindResource("SecondaryAccentBrush") as SolidColorBrush)?.Color) ?? Colors.Magenta;
                        return(marker);
                    })
                                               .DisposeWith(_viewModelDisposables);

                    formattedTextMarkers.ItemsAdded
                    .Subscribe(m => _formattedTextMarkerService.Add(m))
                    .DisposeWith(_viewModelDisposables);

                    formattedTextMarkers.ShouldReset
                    .Subscribe(_ =>
                    {
                        _formattedTextMarkerService.Clear();
                        foreach (var m in formattedTextMarkers)
                        {
                            _formattedTextMarkerService.Add(m);
                        }
                    })
                    .DisposeWith(_viewModelDisposables);

                    //PayloadHexEditor
                })
                .DisposeWith(disposables);

                MessageToken.Events().PreviewTextInput.Subscribe(e => e.Handled = !regex.IsMatch(e.Text))
                .DisposeWith(disposables);
            });
        }