2010-01-06 105 views
3

是我还是MultiScaleImage甚至没有显式宽度和高度显示?出于某种原因,我无法填充网格单元格。它的行为与大多数其他元素不同。Silverlight MultiScaleImage不会填充可用空间

如果我在查看器上放弃高度和宽度,它根本不显示。

编辑:下面是完整的图片... XAML:

<UserControl x:Class="CliqueSite.DeepZoom.Viewer.ZoomPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<Grid x:Name="LayoutRoot" Background="Black"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="34" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*" /> 
    </Grid.ColumnDefinitions> 
    <MultiScaleImage x:Name="Viewer" Margin="1,1,1,0" Height="675" Width="900" /> 
    <Rectangle Grid.Row="1"> 
     <Rectangle.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#FF000000"/> 
       <GradientStop Color="#FF808080" Offset="1"/> 
      </LinearGradientBrush> 
     </Rectangle.Fill> 
    </Rectangle> 
    <Button HorizontalAlignment="Right" Margin="0,0,4,4" VerticalAlignment="Bottom" Padding="6" Grid.Row="1" 
      Content="Zoom Reset" x:Name="ZoomReset" FontSize="9" FontFamily="Verdana" /> 
</Grid> 

相关的代码背后:

[ScriptableMember] 
public void SetSource(int width, int height, int tileSize, int id, string urlToFormat) 
{ 
    Viewer.Source = new ViewerSource(width, height, tileSize, id, urlToFormat); 
    double x = 0; 
    double y = 0; 
    double w = 1; 
    if ((width > height && Viewer.Width > Viewer.Height) || (width > height && Viewer.Width < Viewer.Height)) 
    { 
     double scaleFactor = Viewer.Width/width; 
     double adjustedHeight = height * scaleFactor; 
     double topSpace = (Viewer.Height - adjustedHeight)/2; 
     y = -(topSpace/Viewer.Height) * (Viewer.Height/Viewer.Width); 
    } 
    else 
    { 
     double scaleFactor = Viewer.Height/height; 
     double adjustedWidth = width * scaleFactor; 
     w = Viewer.Width/adjustedWidth; 
     double leftSpace = (Viewer.Width - adjustedWidth)/2; 
     x = -(leftSpace/Viewer.Width) * w; 
    } 
    _viewportOrigin = new Point(x, y); 
    _viewportWidth = w; 
    ResetZoom(); 
} 

Javascript代码(从嵌入对象的onload PARAM运行):

function LoadImage() { 
    var viewer = $("#DeepZoomViewer")[0]; 
    viewer.content.Bridge.SetSource(<%= Model.ZoomProperties.Width %>, <%= Model.ZoomProperties.Height %>, 256, <%= Model.Photo.ID %>, "http://localhost:7070/TileHandler.ashx?id={0}&level={1}&x={2}&y={3}"); 
} 
+0

编辑我的答案。 – AnthonyWJones 2010-01-08 08:24:28

+0

如果确实如此,我会将其标记为答案。 – 2010-07-09 17:15:02

回答

0

尝试更改网格单元定义如下: -

<Grid.RowDefinitions> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="34" /> 
</Grid.RowDefinitions> 
<Grid.ColumnDefinitions> 
    <ColumnDefinition Width=*" /> 
</Grid.ColumnDefinitions> 

它不为MultiscaleImage控制到指定图像的“自然”大小(这将是巨大的)意义。因此,它期望得到大小或延伸到可用的大小。您需要使用*在网格行/列的定义,以确保在电网是地方上的MultiscaleImage控件放置在小区的位置是通过控制的剩余可用大小。

编辑

另外补充

VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 

属性到MSI控制。

+0

不......这里没有快乐。我确信你是对的,但MSI仍然没有高度或宽度。 – 2010-01-08 03:10:18

+0

不...没有变化。如果我将文本块绑定到宽度,它总是显示0: 2010-01-08 22:55:29

1

它填补行0对我就好了,当我设置H/W为Auto,这样的:

<MultiScaleImage x:Name="Viewer" Margin="1,1,1,0" Height="Auto" Width="Auto" /> 

你甚至可以扔在行额外的措施,但它并不需要我的时候做到了这一点:

<MultiScaleImage Grid.Row="0" x:Name="Viewer" Margin="1,1,1,0" Height="Auto" Width="Auto" /> 
+0

工作。我的问题必须得到更深入的研究。我有一个Javascript调用来设置图像源(通过桥),设置为触发对象的onload参数。再说一遍,当我有一个明确的高度/宽度设置。 – 2010-01-10 07:35:01

+0

请考虑发布更多代码,包括js调用和其他可能有助于重现问题的项目。 – 2010-01-10 09:04:05