windows phone 7 - How to Change Size of Images in View when Populated by ObservableCollection -
i have list of images being populated observablecollection. done binding itemssource of listbox collection in code behind. working properly, although list of images results not pretty. images being wrapped in horizontal wrappanel, functionality keep. problem though depending on whether image taken cameracapturetask landscape or portrait mode, either wide or tall when presented in view. able resize these images while keeping aspect ratio in tact. perhaps setting limit on either width or height being no more 128. how in following code? also, image know keep aspect ratio? instance, portrait image know have max height of 128 while maintaining width of less 128 keep aspect ratio?
mainpage.xaml
<listbox x:name="recent" itemssource="{binding}" margin="8" selectionchanged="recent_selectionchanged" toolkit:tilteffect.istiltenabled="true" itemcontainerstyle="{staticresource mystyle}"> <listbox.itemspanel> <itemspaneltemplate> <toolkit:wrappanel orientation="horizontal" /> </itemspaneltemplate> </listbox.itemspanel> </listbox>
you can set itemtemplate
@tanuj_loop suggests suggest potentially embedding item in viewbox
, applying size changes instead of directly image ensure retain resolution of image size constraints you're after, like;
<listbox.itemtemplate> <datatemplate> <viewbox maxheight="128" maxwidth="128"> <image source="{binding }"/> </viewbox> </datatemplate> </listbox.itemtemplate>
this way viewbox
handles potential resizing issues you, , images still come out crisp wanted.
hope helps.
Comments
Post a Comment