I’m trying to put a bigger MediaElement into a smaller Canvas on WPF.
Lets say i’m putting 600×400 media into a 400×300 Canvas with Canvas.Top = -50, Canvas.Left = -100.
And i don’t want the sides that are out of bounds to be displayed, in this case 50 pixels from top and bottom, 100 pixel from right and left of my media should be invisible.
How can i achieve this? Thanks for all the help!
What you are asking for is called “Clipping”. You need to add a
RectangleGeometryto theCanvas.Clipproperty:-