开发者

Silverlight determine height of a textbox

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 sc开发者_JAVA技巧rolldown 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜