简体   繁体   中英

Automatically adjust the height of WebControl

I have a web control with some properties set.Below is the code.

In .CS file :

    webBrowser1.NavigateToString("<html><head></head><body bgcolor=#d5e1f3><p style=font-family:arial><font size=3><center>" + content + "</center></font></p></body></html>"); 

In XAML :

<Grid MinHeight="80" 
              Grid.Row="3"
              Background="Red"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Center">
            <phone:WebBrowser Name="webBrowser1"
                              VerticalContentAlignment="Center" 
                              HorizontalContentAlignment="Center" 
                              MinHeight="80"
                              Foreground="Black" Width="Auto" Height="Auto"></phone:WebBrowser>
        </Grid>

if the text is one line then its not centered vertically.How to fix this ?

Auto sizing doesn't work for the WebBrowser control.

But you could create a workaround by adding script inside which would send the document height outside to your C# app. You could then use that value to manually change the height of the control. Although I am not sure if those two sizes are similar at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM