views:

165

answers:

1

I have a div that holds a Silverlight object tag. From the code on some user action (click on a button) I am expanding the Div to total browser window. I am doing it through Jquery addClass and Remove class. In those classes the difference is position absolute , height width 100% and increased z-index.

It is running well in Ie7 and IE8. But while running through FF it is reloading the Xap when doing it. What can be the reason ? and any solution?

Thanks.

Edit: After some investigation it seems that the reason is because position:absolute. Changing position from relative to absolute is giving the problem. Also once I go from normal mode to fullscreen mode then normal mode. Then expanding it does not load it twice.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

SilverlightApplication1

<style type="text/css">
    .slhost
    {
        width: 642px;
        height: 500px;
        position: relative;
    }
    .bigsl
    {
        width: 100%;
        height: 100%;
        position: absolute;
    }
</style>

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
    function openOverlay() {
        $("#silverlightControlHost").addClass("bigsl");
        $("#silverlightControlHost").removeClass("slhost");
    }
    function closeOverlay() {
        $("#silverlightControlHost").removeClass("bigsl");
        $("#silverlightControlHost").addClass("slhost");
    }
</script>

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">


< Grid x:Name="LayoutRoot" Background="Red" MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown">



</Grid>

using System.Windows;

using System.Windows.Controls; using System.Windows.Input; using System.Windows.Browser;

namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Deployment.Current.Dispatcher.BeginInvoke(() => HtmlPage.Window.Alert("Application Loaded")); }

    private bool _flip;
    private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (_flip)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() => HtmlPage.Window.Invoke("closeOverlay", null));
        }
        else
        {
            Deployment.Current.Dispatcher.BeginInvoke(() => HtmlPage.Window.Invoke("openOverlay", null));
        }
        _flip = !_flip;
    }
}

}

A: 

In firefox, when you hide a DOM element that contains a SL app, the SL application is re-initialized. we used jQuery to remove the object tag, then hide the element:

$("#element object").remove(); $("#element").hide();

...before you do show() you have to re-create the SL object tag. above applies also when replacing a DOM element with $.ajax loaded content.

Please correct me if I'm not understanding ur question correctly.. See one question here...I guess it's the same/related...

Manish
I am not hidding it at any time. I am expanding it to occupy full browser window and when required making it normal again. I am just using addClass and removeClass. I will have a try of what you have suggested.
Tanmoy