Data-binding taking to long to update
- by Justin
In my application I have this code in my view model:
hiddenTextContainer.PreHideVerticalOffset = VerticalOffset;
hiddenTextContainer.HiddenText = Text.Remove(SelectionStart, SelectionLength);
hiddenTextContainer.HasHiddenText = true;
hiddenTextContainer.NonHiddenTextStart = SelectionStart;
Text = Text.Substring(SelectionStart, SelectionLength);
SelectionStart = Text.Length;
hiddenTextContainer.ImmediatePostHideVerticalOffset = VerticalOffset;
This code is used to hide selected text in a textbox. Text is a string property data bound to the text property of a textbox and VerticalOffset is a double property data bound to the VerticalOffset property of that same textbox.
I need to save the VerticalOffset before and after the hiding of selected text takes place, but with my code below both hiddenTextContainer.PreHideVerticalOffset and hiddenTextContainer.ImmediatePostHideVerticalOffset are always set to the same value no matter what.
I have figured out that this is because the text of the textbox has not been updated by the time the code reaches:
hiddenTextContainer.ImmediatePostHideVerticalOffset = VerticalOffset;
Is there any way I can fix this?