Silverlight MultiScaleImage 不会填充可用空间

标签 silverlight deepzoom multiscaleimage

是我的问题还是 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 参数运行):

   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}");
}

最佳答案

当我将 h/w 设置为“自动”时,它可以很好地填充第 0 行,如下所示:

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

您甚至可以将其放入 Row 中以进行额外测量,但我这样做时不需要它:

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

关于Silverlight MultiScaleImage 不会填充可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2011531/

相关文章:

c# - 如何更改Windows Phone 应用程序中按钮的背景颜色?

c# - Silverlight 页面与用户控制方法

silverlight - 哪种Silverlight MVVM测试项目类型?

javascript - 显示数据库中的图像 block

c# - Silverlight MultiScaleImage 的源属性

matlab - 使用riesz变换分析后的相移图像内容

.net - 如何在 Deep Zoom Composer 中添加文本?

c# - 将音频文件流式传输到另一台计算机

silverlight - 使用 Silverlight 和 DeepZoom 的优秀示例站点?