Saturday, July 10, 2010

Silverlight webpart drag and drop not working

Scenario:
I wrote a new Silverlight webpart and was using Drag and Drop functionality. But as soon as I use this inside share point, drag and drop stopped working.

Solution:
As I was using OOTB Silverlight webpart to load the XAP. Silverlight webpart set Windowless property to TRUE by default and this is what caused the issue.

So I exported the exisiting ootb webpart definition DWP file on desktop, edited the Windowless property to False and uploaded the webpart again and it works.

Also you can copy the below XML into a DWP file and upload it to sharepoint.

silverlightdragdrop

Code ( Silverlight_WindowLess_Webpart.dwp ):

<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.SilverlightWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="HelpUrl" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="Hidden" type="bool">False</property>
<property name="AllowEdit" type="bool">True</property>
<property name="Direction" type="direction">NotSet</property>
<property name="TitleIconImageUrl" type="string" />
<property name="AllowConnect" type="bool">True</property>
<property name="HelpMode" type="helpmode">Modal</property>
<property name="CustomProperties" type="string" null="true" />
<property name="AllowHide" type="bool">True</property>
<property name="Description" type="string">A web part to display a Silverlight application.</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="MinRuntimeVersion" type="string" null="true" />
<property name="ApplicationXml" type="string" />
<property name="AllowMinimize" type="bool">True</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="CustomInitParameters" type="string" null="true" />
<property name="Height" type="unit">300px</property>
<property name="ChromeType" type="chrometype">Default</property>
<property name="Width" type="unit">400px</property>
<property name="Title" type="string">Silverlight Web Part</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="TitleUrl" type="string" />
<property name="Url" type="string"></property>
<property name="WindowlessMode" type="bool">False</property>
</properties>
</data>
</webPart>
</webParts>

3 comments:

Anonymous,  November 3, 2010 at 8:59 PM  

how do you export OOB webpart ?

Anonymous,  November 3, 2010 at 8:59 PM  

how do you export OOB webpart

Sandeep K Nahta November 4, 2010 at 1:03 AM  

Edit the Webpart > In Advanced Section > Under export section > make sure Export All is selected > once you save that setting.. under Edit the webpart you will see Export option now....