Open AngryCarrot789 opened 6 days ago
Workaround:
textBox.Focus();
textBox.SelectAll();
TextPresenter? presenter = textBox.FindDescendantOfType<TextPresenter>(false);
if (presenter != null) {
presenter.CoerceValue(TextPresenter.SelectionStartProperty);
presenter.CoerceValue(TextPresenter.SelectionEndProperty);
}
You are assuming text is also synced in time. I guess the TextPresenter still holds the old value. It was never a good idea to sync state via bindings.
Describe the bug
From what I can tell, it seems like the TemplateBinding used to bind a TextBox's SelectionEnd property to the TextPresenter's SelectionEnd property does not get updated quickly enough when the TextBox's SelectionEnd changes, and as a result, the TextPresenter is rendered with a previous value.
To Reproduce
Set a
TextBox
'sIsVisible
property to true (when it was previously false), then set theText
to anything, thenFocus()
it and then invokeSelectAll()
. It will select an amount of characters equal to I assume the length of theText
beforeIsVisible
was set to falseExpected behavior
It should select the exact number of chars
Avalonia version
11.2.999-cibuild0048720-alpha
OS
Windows
Additional context
Here is a debug screenshot, the evaluator says the TextBox's selection end is 9, but the TextPresenter's is 5