using wpf mvvm'ish style. trying create ribbongallery items clickable reason cannot items launch delegate command
xaml code:
<ribbonmenubutton largeimagesource="images/deleteuser1.png" label="delete"> <ribbongallery> <ribbongallerycategory itemssource="{binding availibleusers}" header="user list"> <ribbongallerycategory.itemtemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="*" /> </grid.columndefinitions> <image source="images/deleteuser1.png" width="25"/> <contentpresenter content="{binding}" grid.column="1"> <contentpresenter.inputbindings> <mousebinding mouseaction="leftclick" command="{binding commanddeleteallpermissions}"/> </contentpresenter.inputbindings> </contentpresenter> </grid> </datatemplate> </ribbongallerycategory.itemtemplate> </ribbongallerycategory> </ribbongallery> </ribbonmenubutton> the datacontext has been set view model. viewmodel:
public delegatecommand commanddeleteallpermissions { { return new delegatecommand(delegated_deleteallpermissions); } } private void delegated_deleteallpermissions(object obj) { \\todo:stuff } i have tested command using standard button , triggers, using specific xaml code cannot clickable items in ribbongallery control.
any ideas?
galleries sort of categorized lists, items can checked. suitable, when need options menu, user should check/uncheck items:

this xaml data-bound gallery , sample view model:
<ribbonmenubutton label="foogallery"> <ribbongallery> <ribbongallerycategory itemssource="{binding galleryitems}"> <ribbongallerycategory.itemcontainerstyle> <style targettype="{x:type ribbongalleryitem}"> <setter property="content" value="{binding content}"/> <setter property="isselected" value="{binding isselected}"/> </style> </ribbongallerycategory.itemcontainerstyle> </ribbongallerycategory> </ribbongallery> </ribbonmenubutton> here galleryitems collection of these view models:
public class galleryitem { public object content { get; set; } public bool isselected { { return isselected; } set { if (isselected != value) { isselected = value; // todo: here, when item becomes selected/checked; // handle property changing instead of commands } } } private bool isselected; } if need dropdown menu execute commands, should use regular ribbonmenuitems:

this how should done, when menu items statically known:
<ribbonmenubutton label="foo"> <ribbonmenuitem header="bar1" command="{binding bar1command}"/> <ribbonmenuitem header="bar2" command="{binding bar2command}"/> <ribbonmenuitem header="bar3" command="{binding bar3command}"/> </ribbonmenubutton> when using itemssource menu items, xaml this:
<ribbonmenubutton label="foo" itemssource="{binding menuitems}"> <ribbonmenubutton.itemcontainerstyle> <style targettype="{x:type ribbonmenuitem}"> <setter property="header" value="{binding header}"/> <setter property="command" value="{binding command}"/> </style> </ribbonmenubutton.itemcontainerstyle> </ribbonmenubutton> where menuitems collection of these view models:
public class menuitemvm { public object header { get; set; } public icommand command { get; set; } }
Comments
Post a Comment