In my previous blog post, I discussed how to hide the navigation UI of xbap while you host Xbap (XAML browser application) in iframe. Note that xbap can be accessed directly from browser's URL address and can also be viewed in an iframe in an existing web site. In both cases, a user can have contents that require scrolling. If user developed the xbap application in such a way that the application will be accessed directly form URL address, the user can archive the goal by adding a "
scrollableview" element in your XAML page. A code sample is provided below:
Next case is if user hosted the xbap application in an iframe. In this case, there is a good chance that the user will be viewing two vertical scrollbars in user's browser if user's existing site's page is long enough to cause view a vertical scroll bar, that is the browser's vertical scrollbar. Xbap host have a defined size, which generally as long and wide as the browser window. So if your content is longer than the size of xbap host, you can lose your content from viewable content area, or you will end up having two scrollbars. Well, there are several solutions to this problem. Let's discuss with a simpler version. Make the iframe's height property as long as the xbap that is hosting the xbap. And make sure that your xbap will not grow larger than that. But if your xbap has variable content and has variable height and you got to keep the constant look, you need to do some engineering to keep things smooth. Xbap supports get and set of cookie in the site of origin. So do calculate your height for your content in xbap and then set the height as a cookie, make sure you do set the height of the content as a cookie each time the content of xbap has changed, of course in case of the content that cause the xbap to change its size. Here is a code example to set cookie for site from xbap.
Application.SetCookie(BrowserInteropHelper.Source, "HEIGHT=" + DemoHeight );
c_start=document.cookie.indexOf(c_name + "=");
c_start=c_start + c_name.length+1;
if (c_end==-1) c_end=document.cookie.length;
var hight = getCookie('HEIGHT');
if(hight != "")
hight = 600;
document.getElementById('framename').height = hight;