powershell - Binding SelectedItem to IsChecked -


i have listbox modified check boxes. bind selecteditem check can use $wpflbsitelist.selecteditem basis of selecting items checked.

basically, have generated list need checks equate selected item. selected item needs work in multi selection capacity rather 1 @ time.

<listbox x:name="lbsitelist" selectionmode="multiextended" margin="355,45,411,1014" itemssource="{binding .}">      <listbox.itemtemplate>            <datatemplate>                <checkbox content="{binding .}" ischecked="{binding relativesource={relativesource ancestortype={x:type listboxitem}}, path=isselected}" margin="2,2,0,0"/>            </datatemplate>      </listbox.itemtemplate> </listbox> 

my function write console of checked items selected.

$wpfbtnupdate.add_click({       #list sites ticked     foreach ($wpflbsitelist.items in $wpflbsitelist){          $x=$wpflbsitelist.selecteditems          write-host $x     } }) 

as noted in comments can bind checkbox ischecked value isselected of it's relative ancestor (the listbox) with:

<checkbox ischecked="{binding relativesource={relativesource ancestortype={x:type listboxitem}}, path=isselected" /> 

your real issue, however, seems you're using invalid value listbox' selectionmode property.

in wpf, valid selection modes are:

extended   - user can select multiple consecutive items while holding down shift key. multiple   - user can select multiple items without holding down modifier key. single     - user can select 1 item @ time. 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -