c# - WPF Expander inside ListBox ItemTemplate IsExpanded Default value -


i have expander inside listbox itemcontrol.itemtemplate. after data bound listbox, expanders on each listitem has isexpanded = false. need have isexpanded default true when new listitem added listbox manually. xaml follows:

    <listbox     scrollviewer.horizontalscrollbarvisibility="hidden"      scrollviewer.cancontentscroll="false"      virtualizingstackpanel.isvirtualizing="false"      grid.columnspan="2"      horizontalalignment="stretch"      grid.row="2"      name="arbitrarydatalistbox"     itemssource="{binding elementname=currentarbitrarydatalistcontrol, path=currentjob.additionaldata}">     <listbox.resources>         <style targettype="{x:type expander}">             <setter property="isexpanded" value="{binding path=isselected, relativesource={relativesource ancestortype={x:type listboxitem}}}"/>             <setter property="borderthickness" value="1"/>             <setter property="borderbrush" value="beige"/>             <setter property="foreground" value="#202020"/>             <setter property="background" value="beige"/>         </style>     </listbox.resources>     <itemscontrol.itemtemplate>         <datatemplate>             <expander header="{binding path=name}" margin="0,8,0,0" isexpanded="{binding relativesource={relativesource self}, elementname=arbitrarydatalistbox, path=}">                 <controls:arbitrarydatacontrol                      width="{binding elementname=arbitrarydatalistbox, path=actualwidth, converter={staticresource subtractconverter}, converterparameter=10}"                      currentarbitrarydata="{binding}"                      currentjob="{binding elementname=currentarbitrarydatalistcontrol, path=currentjob}"/>             </expander>         </datatemplate>     </itemscontrol.itemtemplate> </listbox> 

i'm new wpf , can't head around how set binding on isexpanded true when new items manually open.

thank can provide!

if i'm understanding code, right have selecteditem of listbox expanded , other items collapsed. if selected item changes, old selected item collapse , new selected item expand.

if want able add item collection , select it, should consider using listcollectionview.

listcollectionview wraps around inner collection , exposes "currentitem". can bind class listbox allow call listcollectionview.movecurrentto(object) select object after add it.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -