views:

137

answers:

2

Good Day,

I have a scrollview control that has a StackPanel (Orientation=Vertical) UI Element inside of it. I have a series of textboxes (24) inside the StackPanel. The scrollviewer height = 250px. Ideally, what I want is when I start to tab from textbox to the next textbox, I want the scrollview to automatically scrolldown without user interaction.

I have code that successfully does this. How would I go about computing what the Textbox height is?

My code looks something like:

private void TB_GotFocus(object sender, RoutedEventArgs e)  
{  
    if (sender is TextBox)  
    {
        TextBox tb = (TextBox)sender;

        // but using tb.Height does not obtain the value for me.  It returns a NaN  
    }  
}  

Any suggestions or comments otherwise would be helpful.

+1  A: 

You need to use the ActualHeight property. That will give you what you want.

Joseph
+2  A: 

You should look at TextBox.ActualHeight to get the height. The Height property is an indication of the height the TextBox desires, not the actual height.

Martin Liversage

related questions