缩放视觉画笔背景 WPF
我的 xaml 中有一个名为 MiniMap 的项目。我已将其背景设置为代表画布项目的视觉画笔。现在,我想将背景缩放到比率 0.7 。我该怎么做呢? 提前致谢
<local:MiniMap Width="201" Height="134" x:Name="MiniMapItem" MinHeight="100" MinWidth="100" Opacity="1" SnapsToDevicePixels="True" Margin="0,0,20,20" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<local:MiniMap.Background>
<VisualBrush Visual="{Binding ElementName=viewport}" Stretch="None" TileMode="None" AlignmentX="Left" AlignmentY="Top" />
</local:MiniMap.Background>
</local:MiniMap>
I have a Item called MiniMap in my xaml. I have set the background of it to a visual brush representting a canvas Item. Now, I want to scale the background to a ratio 0.7 . How can I do it?
Thanks in advance
<local:MiniMap Width="201" Height="134" x:Name="MiniMapItem" MinHeight="100" MinWidth="100" Opacity="1" SnapsToDevicePixels="True" Margin="0,0,20,20" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<local:MiniMap.Background>
<VisualBrush Visual="{Binding ElementName=viewport}" Stretch="None" TileMode="None" AlignmentX="Left" AlignmentY="Top" />
</local:MiniMap.Background>
</local:MiniMap>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
您可能需要使用 CenterX 和 CenterY 属性才能使其看起来正确。通常您会希望将它们设置为要缩放的中间点。
Try this:
You may need to play with the CenterX and CenterY properties to get it to look right. Usually you'll want them to be set to the middle point of what you're scaling.
VisualBrush 元素具有 Viewbox 属性,可用于缩放背景。
The VisualBrush element has the property Viewbox, which can be used to scale the background.