简体   繁体   中英

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.

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

OUTPUT:

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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