2012-09-19 48 views
0

假设2个图像,大背景和前景较小。前景完全停留在背景的中间,覆盖相对数量(例如50%),以便用户将它们视为单个图像。当调整窗口大小时,保持两个图像相对缩放

问题是我需要背景填充各种大小的Window。将它的Stretch值设置为UniformToFill将会这样做。但是,我怎样才能保持前景仍然覆盖背景的50%?

回答

0

使用矢量图像会更好,因为当您调整其容器大小时,它可以缩放'本身'

然后你根据如下的窗口大小设置边距:

<Window x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Height="400" Width="400"> 
<Grid> 
    <Image Margin="100"> 
     <Image.Source> 
      <DrawingImage> 
       <DrawingImage.Drawing> 
        <GeometryDrawing Brush="#FF000000" Geometry="M14.800615,5.6499605L14.800615,14.800346C10.630442,17.910477 7.8903284,22.840685 7.8903284,28.44092 7.9003286,37.871319 15.530646,45.511639 24.961039,45.521641 34.391431,45.511639 42.011749,37.871319 42.04175,28.44092 42.03175,22.840685 39.291636,17.910477 35.121462,14.800346L35.121462,5.6599612C43.841825,9.5601254,49.912077,18.280493,49.912077,28.44092L49.922077,28.44092C49.912077,42.231503 38.741611,53.391972 24.961039,53.391972 11.170465,53.391972 0,42.231503 0,28.44092 0,18.270493 6.0902529,9.5501251 14.800615,5.6499605z M19.570043,0L30.237043,0 30.237043,33.917 19.570043,33.917z" /> 
       </DrawingImage.Drawing> 
      </DrawingImage> 
     </Image.Source> 
    </Image> 
</Grid> 

始终使用窗口的50%,你可以使用一个Converter绑定属性。

此外,也许this可以帮助你。

相关问题