This is a migrated thread and some comments may be shown as answers.

Resizing panel besed on content size

1 Answer 105 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Vassili King
Top achievements
Rank 1
Vassili King asked on 24 Sep 2010, 09:39 PM
Hello,

I have RadPanelBar with 3 RadPanelItems.  Each RadPanelItem hosts a Silverlight app (RadGridViews mostly)  that have some number of database records displayed and an interface to input query parameters (searching for records, filtering, etc.).  Every Silverlight app differs in height based on the number of records returned for any given request, thus making their height variable.  Is there a way to resize the RadPanel size in response to every change in the size of the Silverlight app's content?

Also, if I have the Silverlight apps inside of SharePoint Web Parts (which, in turn, are placed inside RadPanelItems), how much would it complicate things?

Thank you!
-VK. 

1 Answer, 1 is accepted

Sort by
0
Vassili King
Top achievements
Rank 1
answered on 27 Sep 2010, 08:01 PM

Neve mind.  I've got it resolved using some JavaScript and some code behind.  That is, in Silverlight app I'm setting a value of a hidden field (myHiddenField) with the desired size of an accordion panel like so:

HtmlDocument doc = HtmlPage.Document;

doc.GetElementById("myHiddenField").SetProperty("value", GetNecessaryHeight());

Here, the GetNecessaryHeight() calculates the hight based on the current number of rows in the grid.  The code above is executed on the DataLoaded event for the grid.

On  the client side, my JavaScript code looks for the value of the myHiddenField field, validates the value, and sets the height of the <object...> element containing my Silverlight app.  This stretches/shrinks the surrounding accortion panel (RadPanelItem).  the JavaScript function that does validation/resizing is attached to a timer (which runs it every .2 of a second) like so:

window.setInterval(myValidatingAndResizingFunction, 200);

I've ran into a problem with this approach on the accordion panels other than the first one - the resizing would reload the Silverlight control if it isn't in the first panel.  This was easily fixed by placing the <object...> element inside of a AJAX UpdatePanel.

Tags
PanelBar
Asked by
Vassili King
Top achievements
Rank 1
Answers by
Vassili King
Top achievements
Rank 1
Share this question
or