我正在使用Silverlight 3.0圖像控件,將其設置爲Stretch property =「Uniform」。除非我錯了,Stretch =「Uniform」的預期行爲是它應該縮放圖像,保持縱橫比,按需要放置信箱。這適用於具有橫向取向的圖像,因爲它們可以放大以填充空間,保持縱橫比而不切斷任何圖像。對於更垂直或「縱向」方向的圖像來說,這是完全失敗的。除了放大以適應圖像控制之外,它們實際上會縮放高度限制,以至於只能看到圖像的中間部分,並且頂部和底部被截斷。它就好像控件只在縮放時使用寬度,並忘記檢查高度?Silverlight Image Stretch =「Uniform」Portrait for Size Images
這是圖像控制中的錯誤,還是我缺少或錯誤設置屬性?要重現,找到/創建一個'肖像'縱橫比(高於它的寬度)的圖像,並創建一個與拉伸=「統一」的圖像。
****更新請求的XAML ****** 請注意,大小不明確的原因是爲了允許全屏和縮放。
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="9"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Border BorderBrush="Black" Grid.Row="0" Grid.ColumnSpan="8" BorderThickness="1, 1, 1, 0">
<Border BorderBrush="{StaticResource blackStatusMapLGB}" BorderThickness="9,9,9, 0">
<Border BorderBrush="Gray" BorderThickness="1, 1, 1, 0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<MediaElement Height="Auto" Width="Auto" Visibility="Collapsed" AutoPlay="true" Stretch="Fill" MediaFailed="SilverlightMediaPlayer_MediaFailed" Name="previewMediaElement"/>
<Image Name="imagePreview" Stretch="Uniform"/>
</StackPanel>
</Border>
</Border>
</Border>
奇怪的是,如果我簡單地刪除堆疊面板,它可以正常工作......不需要在樹的上方任何位置定義高度? – PortageMonkey 2009-09-11 23:32:59