简体   繁体   English

在WPF和Blend中添加纹理形状

[英]adding texture to shape in WPF and Blend

How can I add a texture to a let's say rectangle such when I stretch the object on canvas it would cover up while being resized? 如何在矩形上添加纹理,例如在画布上拉伸对象时会在调整大小时覆盖它?

Thank you 谢谢

not that I care about negative points but those who leave this kind of scoring at least could be a little beneficial by pointing to a solution since they feel this is a low level question so I'm assuming they know the answer. 不是说我在乎负面点,而是那些至少离开这种得分的人通过指出一个解决方案可能会有所帮助,因为他们认为这是一个低级的问题,所以我假设他们知道答案。 I have searched on blend 4 and related topics to xaml but did not find a direction. 我已经搜索了xaml的blend 4和相关主题,但没有找到方向。

Add the image as an imagebrush for the fill of the rectangle: 将图像添加为用于填充矩形的图像画笔:

<Rectangle Width="auto" Height="auto" Name="myRectangle">
    <Rectangle.Fill>
        <ImageBrush ImageSource="C:\Users\Public\Pictures\Sample Pictures\sample.gif"/>
    </Rectangle.Fill>
</Rectangle>

SOURCE: http://social.msdn.microsoft.com/Forums/en/wpf/thread/4c70e94b-23a1-4533-9332-eaa08bcf113d 源: http : //social.msdn.microsoft.com/Forums/en/wpf/thread/4c70e94b-23a1-4533-9332-eaa08bcf113d

OUTPUT: 输出:

image credit: http://googleblog.blogspot.com/2012/03/bringing-self-driving-cars-to-nascar.html 图片来源: http : //googleblog.blogspot.com/2012/03/bringing-self-driving-cars-to-nascar.html

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM