views:

66

answers:

2

Hello all,

I've got the most annyoing case here: I've created a small silverlight application that loads an image from a remote path. The image is very wide, therefore it does not fit into the page properlly. When I view the image in the aspnet page, From some reason the silverlight application is cut to fit the current width of the page. When I set the width of the silverlight application on the aspnet page to a different value more of the image reveals. I cannot guess the width of the image each time! What to do?

The silverlight Code:

  <Canvas x:Name="LayoutRoot">
 <Image Name="imgTrack"></Image>
</Canvas>

The Aspnet Code:

<body>
<form id="form1" runat="server">
<div id="silverlightControlHost" style="overflow:auto;">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
   <param name="source" value="ClientBin/MidiSLMixer.xap"/>
   <param name="onError" value="onSilverlightError" />
   <param name="background" value="white" />
   <param name="minRuntimeVersion" value="3.0.40624.0" />
   <param name="autoUpgrade" value="true" />
   <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;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="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
   </div>
</form>

Thank you!

A: 

You've got two choices.

Silverlight App dynamically sizes the containing object

Once you've downloaded the image you could have the Silverlight app access the containing DIV and give it a specific width (note give the object tag width 100% also).

Silverlight handles the scrolling

Another approach is to drop the image in a ScrollViewer control and let that handle the scrolling.

AnthonyWJones
A: 

What about scaling the image to fit your available space? Would that approach work?

scottmarlowe