wieslawsoltes/Dock

Help!I don't

idea-zone opened this issue · 1 comments

Before I add the SimpleReplaceViewModel to FileViewModel : Document , it's allow right,But when I do it, it's wrong in OnAttached to get targetEditor .

In TextHighlightBehavior : Behavior<TextBox> I add the code:

public class TextHighlightBehavior : Behavior<TextBox>
{
// ....
 public static readonly AttachedProperty<TextEditor> TargetEditorProperty =
            AvaloniaProperty.RegisterAttached<TextHighlightBehavior, TextBox, TextEditor>("TargetEditor");
        public static TextEditor GetTargetEditor(TextBox textBox)
        {
            return textBox.GetValue(TargetEditorProperty);
        }
        public static void SetTargetEditor(TextBox textBox, TextEditor value)
        {
            textBox.SetValue(TargetEditorProperty, value);
        }

        protected override void OnAttached()
        {
            base.OnAttached();

            var targetEditor = GetTargetEditor(AssociatedObject);
            AssociatedObject.PropertyChanged += OnAssociatedObjectPropertyChanged;
         
            AssociatedObject.TextChanged += OnTextChanged;
        }

//...
}

And in SimpleReplaceView.axaml I use as :

<TextBox Width="303"   Text="{Binding SearchText}" AcceptsReturn="True" TextWrapping="Wrap"
                     uiExtensions:TextHighlightBehavior.TargetEditor="{Binding #TxtInputEditor}"  >
              
				<Interaction.Behaviors >
					<uiExtensions:TextHighlightBehavior SearchText="{Binding SearchText,Mode=OneWay}"  />
				</Interaction.Behaviors>
 </TextBox>

<AvaloniaEdit:TextEditor Grid.Column="0" x:Name="TxtInputEditor"
                                     VerticalScrollBarVisibility="Auto"
                                     HorizontalAlignment="Center" VerticalAlignment="Center"
                                     Document="{Binding InputTextDocument}"
                                     ShowLineNumbers="True"
                                     Width="400"
                                     FontFamily="Cascadia Code,Consolas,Menlo,Monospace">
</AvaloniaEdit:TextEditor>

The FIleViewModel

  public class FileViewModel : Document
    {
        public ViewModelBase Content { get; set; } = new SimpleReplaceViewModel();
    } 

I know why , I not need change ViewModelBase: ReactiveValidationObject to ViewModelBase: ObservableObject to make

 public IRootDock? Layout
    {
        get => _layout;
        set => SetProperty(ref _layout, value);
    }

Just do use it replace:

[Reactive]
 public IRootDock? Layout
    {
        get ;
        set;
    }

It may be a diffrent way to use ObservableObject and Behavior