【问题标题】:Tile vector image as background平铺矢量图像作为背景
【发布时间】:2015-07-27 07:40:30
【问题描述】:

亲爱的朋友们! 我的资源字典中有无缝矢量图像作为画布

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas x:Key="SeamlessBackground" 
  ...   
</Canvas>

我想用它作为我的 MainWindow 背景。我使用了 VisualBrash:

<Window.Background>
    <VisualBrush Stretch="None" Visual="{StaticResource SeamlessBackground}" TileMode="Tile" >
        <VisualBrush.Transform>
            <TransformGroup>
                <ScaleTransform ScaleX="0.2" ScaleY="0.2"/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </VisualBrush.Transform>
    </VisualBrush>
</Window.Background>

但我得到的不是大的无缝背景,而是几个分离的图像,它们之间有巨大的接缝。当我伸展我的身体时,这些接缝就是增长。我预计当我拉伸表格时,新图像会被淹没以填补这些接缝。 请帮忙)))

【问题讨论】:

    标签: wpf vector background tile


    【解决方案1】:

    我自己找到了答案)))

    关键是 ViewPort 中的绝对单位而不是相对单位:

    <Window.Background>
        <VisualBrush Visual="{StaticResource SeamlessBackground}" TileMode="Tile" 
          ViewportUnits="Absolute" 
          Viewport="0,0,100,100"/>
    </Window.Background>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多