ItemsControl and bind multiple elements to the same property


hello everyone

got 2 questions you:

1. how can bind border visibility property (line 9) property in class?
got list of images (called images) observablecollection<gimage>. if change images source (thumbnail) updates correctly , every thing fine. collapse border when uncheck checkbox therefore have binded visibility to guiitemvisibility, when changing guiitemvisibility nothing happens. idea wrong?

1    <itemscontrol x:name="gallerylist" grid.column="1" itemssource="{binding images, mode=oneway, source={staticresource galleryds}}">  2                <itemscontrol.itemspanel>  3                    <itemspaneltemplate>  4                        <controlstoolkit:wrappanel orientation="horizontal" itemheight="160" itemwidth="180" />  5                    </itemspaneltemplate>  6                </itemscontrol.itemspanel>  7                <itemscontrol.itemtemplate>  8                    <datatemplate>  9                        <border grid.row="0" visibility="{binding guiitemvisibility}" background="white" borderbrush="black" borderthickness="1" margin="5" tag="{binding id}" cursor="hand" mouseleftbuttondown="showpopup">  10                           <grid margin="5">  11                               <image source="{binding thumbnail}" stretch="none" horizontalalignment="center" verticalalignment="center" />  12                               <checkbox tag="{binding id}" ischecked="true" checked="imgcheckbox_click" unchecked="imgcheckbox_click" horizontalalignment="left" verticalalignment="bottom" />  13                           </grid>  14                       </border>  15                   </datatemplate>  16               </itemscontrol.itemtemplate>  17           </itemscontrol>  

 2. how bind 2 images same source?
make reflection of each image in collection make copy of line 9 14 , both images (line 11) has binding thumbnail, first image binding. reflection image empty.


hope can me, safe day :-)

about binding.. can in sl3 use elment binding, example:

visibility="{binding ischecked, elementname=mycheckbox, converter={staticresource visibilityconveter}}

need add converter convert boolean value visibility enum. here example: http://timheuer.com/blog/archive/2008/07/30/format-data-in-silverlight-databinding-valueconverter.aspx

if want bind border's visibility property in class, property must return visibilty enum, if return true , false, need a converter.. if change value of bounded property (your class property), need notify ui changes binding updated.. can done using inotifypropertychanged interface on class: http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(vs.95).aspx

about image part.. don't know if understand correctly, collections can bound itemssource of list control. if bind collection of images list control. list control add items each items in collection. in case the images bound listcontrol's itemssource should list of items equal number of items in collection, , each item use datatemplate have specified..



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607