c# - Show only a section of an image in WPF Datagrid rows? -


i have images (on local drive) of 200x275 in dimension , i'm filling 1 row in data grid them using following code:

xaml : datagrid.columns

<datagridtemplatecolumn header="img" width="sizetocells">     <datagridtemplatecolumn.celltemplate>         <datatemplate>             <image width="200" height="275" margin="0,0,0,-100" source="{binding path=img}" />         </datatemplate>     </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

in xaml.cs file have img property of type bitmapimage (stores uri bitmapimage) , using collectionviewsource update changes list of includes column images.

displaying them fine, want display section of each image sort of preview (same width of 200px, 10px top, , 50px in height - later i'll have full image display when small preview of clicked).

from above bit of code can see tried changing margin values (-100 bottom) - kinda works, last image in list displayed in full , extends past bottom of list.

is there better way of cropping 10px top, , set height 50px without image scaling down?

the way can think of doing creating new bitmap bitmap image i'm pretty sure that'd inefficient hundreds of images.

i'd try wrapping image control in grid cliptobounds=true. should fix it. make sure grid sized item (50px high) , not auto-sized image or clipping won't work expect.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -