开发者

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);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜