We have an image where we create view box coordinates that are topleft/bottom right points within the image that are setup to allow for viewing portions of an image at different times in our application. In WPF, how do we load an image, and with topleft/bottom right points within that image, only show the portion of the image within that view box?
Set your Image source like this: <Image Source={Binding {x:Static UI:Resources. Search}} /> where 'Search' is name of the resource. Save this answer.
You can do this with a CroppedBitmap:
<Image>
<Image.Source>
<CroppedBitmap Source="<path to source image>" SourceRect="20,20,50,50"/>
</Image.Source>
</Image>
This will display the 50x50 region of the image starting at position (20,20)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With