Resizing panel besed on content size

2 posts, 0 answers
  1. Vassili King
    Vassili King avatar
    60 posts
    Member since:
    May 2010

    Posted 24 Sep 2010 Link to this post

    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. 
  2. Vassili King
    Vassili King avatar
    60 posts
    Member since:
    May 2010

    Posted 27 Sep 2010 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top