xaml - Disabling the button based on items selected in the ItemsList -
<button tooltip="duplicate" tooltipservice.showondisabled="true" command="{binding path=duplicateentitycommand }" commandparameter="{binding elementname=gridview, path=selecteditems}"> <image style="{staticresource toolbarimagestyle}" source="/oneplanner;component/resources/icons/duplicate.png"></image> <button.style> <style targettype="{x:type button}" basedon="{staticresource {x:type button}}"> <setter property="isenabled" value="false"/> <style.triggers> <multidatatrigger> <multidatatrigger.conditions> <condition binding="{binding elementname=radgridview, path=selecteditems.count}" value="1"/> <condition binding="{binding path=isitemlistconstainstoyota}" value="false"/> </multidatatrigger.conditions> <setter property="isenabled" value="true"/> </multidatatrigger> </style.triggers> </style> </button.style> </button>
the button tied gridview. have enable button based on selection in selecteditems. if 1 selects 1 items in grid , item not has let string value equal toyota, button should enabled. have created method in viewmodel use commandparameter.
private bool isitemlistconstainstoyota(ilist<object> itemlist) { if (itemlist.first() carlist) { string carname= ((carlist)itemlist.first()).carnameasstring; if (carname.equals("toyota")) { return true; } } return false; }
the code far have not work. there anyway in xaml or have in viewmodel?
for duplicate entity command, can pass action<object>
canexecuteaction. if false, button disabled. try passing following action<object>
canexecuteparameter in icommand.
itemlist => { return isitemlistconstainstoyota(itemlist); }
Comments
Post a Comment