2015-01-24 2 views
0

xaml에 WebBrowser 컨트롤을 만들고 을 만들고 문자열을 통해 일부 HTML을 바인딩합니다. 괜찮 았어. 그러나 WebBrowser는 자동으로 높이를 조정하지 않습니다. 나는 웹 브라우저가Windows Phone 7에서 WebBrowser 컨트롤 높이를 자동 조정하는 방법은 무엇입니까?

1) 자동으로 원하는 것은

<phone:WebBrowser 
    HorizontalAlignment="Stretch" 
    Margin="0,6,0,0" Name="myWebView" 
    VerticalAlignment="Top" /> 

private void WebBrowser_OnLoaded(object sender, RoutedEventArgs e) 
{ 
    String htmlTags = "<html><head><meta charset='UTF-8'/><meta name=\"viewport\" content=\"width='480', initial-scale='1'\"></head><body><center>{0}</center></body></html>"; 
    myWebView.NavigateToString(String.Format(htmlTags, getHTMLContent()); 
} 

public string getHTMLContent() 
{ 
    StringBuilder htmlBody = new StringBuilder(); 
    htmlBody.Append("<table cellpadding=\"0\" cellspacing=\"0\" width=\"704\" height=\"484\" background=\"https://known.com/img/back/123456.jpg\" style=\"background-repeat: no-repeat; background-position: center;\">"); 
    htmlBody.Append("<tr>"); 
    htmlBody.Append("<td valign=top>"); 
    htmlBody.Append("<div style=\"position: absolute;\">"); 
    htmlBody.Append("<div style=\"position: absolute; display: table; width: 132px; height: 132px; top: 44px; left: 44px; z-index:0;\">"); 
    htmlBody.Append("<img src=\"https://known.com/img/icon/87654.jpg\" width=\"100%\" height=\"100%\"/>"); 
    htmlBody.Append("</div>"); 
    htmlBody.Append("<div style=\"position: absolute; display: table; width: 704px; height: 484px; top: 0px; left: 0px; z-index:0; \">"); 
    htmlBody.Append("<img src=\"https://known.com/img/icon/234255.jpg\" width=\"100%\" height=\"100%\"/>"); 
    htmlBody.Append("</div>"); 
    htmlBody.Append("<div style=\"position: absolute; display: table; width: 440px; height: 264px; top: 184px; left: 184px; z-index:0; font-family:times; font-size:14px; color:#FFFFFF; \" align=\"center\">"); 
    htmlBody.Append("<div style=\"display: table-cell;vertical-align: middle;\">"); 
    htmlBody.Append("</div>"); 
    htmlBody.Append("</div>"); 
    htmlBody.Append("</div>"); 
    htmlBody.Append("</td>"); 
    htmlBody.Append("</tr>"); 
    htmlBody.Append("</table>"); 
    return htmlBody.ToString(); 
} 

는 높이가 HTML 문자열에 따라 조정합니다. 하나의 이미지 평균 만 통과하면 자동 조정은 이미지에 따라 달라집니다. 콘텐츠 의미가 없으므로 브라우저 자체를 숨겨야합니다.

2) 스크롤이 가능하지 않아야합니다. 웹 브라우저가 이미 내용에 맞게 높이를 늘려야하기 때문입니다.

어떻게 만들 수 있습니까? 제 문제를 해결할 수있는 아이디어를 알려주세요.

답변

1

렌더링 된 HTML의 높이를 가져와 WebBrowser 컨트롤에 설정하려면 javascript를 사용해야합니다.

여기에 this의 구현이 있습니다.

+0

안녕하세요 .. 링크를 제공해 주셔서 감사합니다 ... 잘 작동하고 있습니다. 하지만 또 하나의 문제에 직면 해 있습니다. 즉, 웹 페이지가 브라우저에서 초과되었습니다. 그러나 페이지를 두 번 클릭하면 웹 페이지가 화면에 맞게 표시됩니다. 제게이 아이디어를 알려주세요. – Vijay

+0

내 다른 문제를 해결할 생각을 해주세요. – Vijay

+0

@vijay 샘플 프로젝트를 어딘가에 업로드하고 정렬을 시도 할 링크를 게시하십시오. –

관련 문제