Showing posts with label SilverLight. Show all posts
Showing posts with label SilverLight. Show all posts

Thursday, August 2, 2012

Silverlight appears on top of pop-up menu

The SharePoint site I'm working on features a top navigation bar that drops down a submenu when the main menu buttons are hovered over.  There's nothing particularly clever going on there - it uses jQuery, and is tied in with the standard SharePoint navigation.

However, a few pages on the site have a Silverlight object at the top of the editable page - so, directly underneath the top navigation bar.  On these pages, the Silverlight object would appear to be always on top, so the pop-up element would always appear behind it.  This means that you couldn't navigate to other areas of the site.

I found a fix on the Silverlight forums that consisted of two parts:

  1. For the DIV that contains the Silverlight object, position: absolute is required.
  2. For the Silverlight object, an additional param is required: windowless should be set to true, like this:  <param name="Windowless" value="true"/>
Problem solved, like magic.

Wednesday, April 4, 2012

Passing Display Language from SharePoint 2010 to a Silverlight app

This is related to cultures, my current obsession.  Running a Silverlight app in a browser will allow you to change the browser language and have the Silverlight app respond appropriately.

SharePoint 2010 has a "Display Language" option for each user - as long as the appropriate SharePoint 2010 language pack has been installed, the SharePoint site will be changed to show translations that have been assigned for that language.  However, as the browser language hasn't changed, Silverlight web parts don't reflect that change.

The solution?  Create a new Silverlight web part control that inherits from System.Web.UI.WebControls.WebParts.WebPart, and in the Render section (that outputs to a supplied HtmlTextWriter called writer) -

            string s = String.Format(@"              
                <div id='SilverlightObjectDiv_{0}' style='display: block; overflow:hidden'>
                    <object class='ms-dlgDisable' id='SilverlightObjectTag_{0}' width='100%' height='{2}'
                        data='data:application/x-silverlight-2,'
                        type='application/x-silverlight-2' >
                        <param name='source' value='{1}'/>
                        <param name='initParams' value='MS.SP.url={3},culture={4}'/>
                        <param name='culture' value='{4}' />
                        <param name='uiculture' value='{4}' />
                        <!-- Display installation image. -->
                        <a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0'
                            style='text-decoration: none;'>
                            <img src='http://go.microsoft.com/fwlink/?LinkId=108181'
                                alt='Get Microsoft Silverlight'
                                style='border-style: none'/>
                        </a>
                    </object>
               <iframe id='_sl_historyFrame' style='border-bottom: 0px; border-left: 0px; width: 0px; display: block; height: 0px; visibility: hidden; border-top: 0px; border-right: 0px'></iframe>&#160;
                </div>      
                ",
                 this.ClientID.ToString(),
                 _xapFileUrl,
                 (this.Height.Value - 20).ToString(),
                 SPContext.Current.Web.Url, System.Threading.Thread.CurrentThread.CurrentUICulture.ToString()                
                 );


            writer.Write(s);

The important thing to note here is the "culture" and "uiculture" params - System.Threading.Thread.CurrentThread.CurrentUICulture would normally pass the browser language but when running as a SharePoint web part, seems to pass the chosen display language instead.

Tuesday, April 3, 2012

Silverlight Localization

Two useful links for localizing Silverlight applications:

http://www.michaelsnow.com/2010/04/28/silverlight-tip-of-the-day-7-localized-resources/ walks you through the process of making your app culture-observant.

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/10/27/10864.aspx enables you to use your browser language settings to determine the culture automatically.

Wednesday, March 28, 2012

FLV files in SharePoint

Microsoft Expression Encoder. 'Nuff said. I keep finding out new reasons to love Microsoft Expression. It's still missing a good photo editing option though.

Converters in XAML

On a Silverlight course this week. When working with data in WPF or SilverLight, you can bind data to properties, such as background colour. However, you will need to convert it to an actual colour. This can be done in WPF using triggers, but if you want to use code, create a new class that inherits from IValueConverter, and you can use that helpful little "Apply Data Binding" wizard to assign the converter to a property. Very useful.