Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: RE: Silverlight WebResource is not getting resized even if the hosted entity gets re-sized after taking rollup12

$
0
0

Tirtha, or in case anybody else is interested, we have also found the resizing solution or rather a workaround for the scenario when we place Silverlight control directly on CRM entity form. Thanks Javaid for your tips.

In Silverlight Webresource Properties dialog / Formatting / Silverlight Control Properties / Size, we need to select the "Specific size" option" as "Use Available Area (Stretch to fit)" does not work. For example in our case we intentionally selected large width of 2000 pixels as a trick.

We usesome JS files also on our entity form. On Form Properties / OnLoad event, we call a function initForm which does some basic things whenever this entity form is opened. In this function we attached a function to the window's onresize event. This function basically informs Silverlight control whenever the entity form is resized and then Silverlight code get the current viewport width in which it is placed and resizes itself according to that. Please note that in our case we were interested in only resizing width of out Silverlight control.

JS Code:

function initForm () {

   //...

   window.onresize = function (event) {

               //Get Silverlight control by passing its webresource name and call its public function

               var control = Xrm.Page.getControl('WebResource_SilverlightAddon');

               var silverlightPlugin = control.getObject();

               var result = silverlightPlugin.Content.interactionObject.AddonResize();

           }

   //...

}

Silverlight code:

[ScriptableMember()]

public void AddonResize()

{

   ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");

   ScriptObject page = (ScriptObject)xrm.GetProperty("Page");

   ScriptObject ui = (ScriptObject)page.GetProperty("ui");

   double tabWidth = (double)ui.Invoke("getViewPortWidth");

   MainGrid.Width = tabWidth;

}

You will also need to add a call to AddonResize() in the constructor of the Silverlight control so that control resizes itself properly in case of refresh because in that case we are not going to get resize event from browser window.

Cheers,

Shiv


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>