Data-binding taking to long to update

Posted by Justin on Stack Overflow See other posts from Stack Overflow or by Justin
Published on 2010-04-24T18:05:48Z Indexed on 2010/04/24 18:13 UTC
Read the original article Hit count: 189

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about databinding

Related posts about textbox