Dynamic height for silverlight app in sharepoint
So as far as I know 开发者_运维知识库when using Silverlight in Sharepoint I need to give the web part a certain height and width for the silverlight application that I want to use. And I cant use 100% in the web part properties.
What I would like to do is for the silverlight app to tell the webpart what the height should be.
Currently I'm not even sure how I can calculate the required height of the silverlight app, the height will depend on how much data is loaded into the app. But if I can set the height in Sharepoint, its pointless even getting that far!!!
Any help with either point would be great.
Cheers
Call a javascript function when your main x:Grid loads that does the resize for you:
<Grid x:Name="LayoutRoot" Loaded="LayoutRoot_Loaded" .../>
On your .xaml.cs:
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
{
HtmlPage.Window.Invoke("fixWebPartHeight", LayoutRoot.ActualHeight);
}
And your page script (jQuery sample)
function fixWebPartHeight(height)
{
// set an unique id wrapping the content of your webpart
$("#myCustomWebPart").height(height);
}
精彩评论