c# - Determining when Listbox has finished loading bound elements -



c# - Determining when Listbox has finished loading bound elements -

i have listbox bound collection of objects, , works except don't know how phone call code need executed when item in list selected.

to clear, have hooked listbox_selectionchanged event when user selects different item - , works fine.

when listbox is first shown, though, want phone call same code on first item in list, defaults to. listbox_bounddatafinishloading, or something..

any ideas?

you hook itemlist-changed event , select first item after added:

public mywindow() { initializecomponent(); ((inotifycollectionchanged)listbox.items).collectionchanged += listbox_collectionchanged; } private void listbox_collectionchanged(object sender, notifycollectionchangedeventargs e) { if (e.action == notifycollectionchangedaction.add && listbox.selecteditem == null) { listbox.selecteditem = e.newitems[0]; } }

c# wpf data-binding listbox binding

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -