xaml - Unable to apply menu flyout to listview -
i unable apply menu flyout listview. assume app crashes once app attempts load specified xaml.
my code below:
xaml:
<listview x:name="contactlist" scrollviewer.verticalscrollbarvisibility="visible" itemssource="{binding selectedcategory.contacts}" selecteditem="{binding selectedcontact, mode=twoway, converter={staticresource nulltoboolconverter}}" displaymemberpath="name"> <listviewitem> <interactivity:interaction.behaviors> <core:eventtriggerbehavior eventname="holding"> <behaviors:movecontactbehavior /> </core:eventtriggerbehavior> </interactivity:interaction.behaviors> <flyoutbase.attachedflyout> <menuflyout> <menuflyoutitem text="family" command="{binding movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> <menuflyoutitem text="friend" command="{binding movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> <menuflyoutitem text="business" command="{binding movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> </menuflyout> </flyoutbase.attachedflyout> </listviewitem> </listview> behavior:
public class movecontactbehavior : dependencyobject, iaction { public object execute(object sender, object parameter) { var senderelement = sender frameworkelement; flyoutbase flyoutbase = flyoutbase.getattachedflyout(senderelement); flyoutbase.showat(senderelement); return null; } }
i fixed it.
i removed displaymemberpath listview , added datatemplate. works now.
<textblock text="{binding displayname}"> <interactivity:interaction.behaviors> <core:eventtriggerbehavior eventname="holding"> <behaviors:movecontactaction /> </core:eventtriggerbehavior> </interactivity:interaction.behaviors> <flyoutbase.attachedflyout> <menuflyout> <menuflyoutitem text="family" command="{binding elementname=grid, path=datacontext.movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> <menuflyoutitem text="friend" command="{binding elementname=grid, path=datacontext.movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> <menuflyoutitem text="business" command="{binding elementname=grid, path=datacontext.movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> <menuflyoutitem text="others" command="{binding elementname=grid, path=datacontext.movecommand}" commandparameter="{binding relativesource={relativesource self}, path=text}" /> </menuflyout> </flyoutbase.attachedflyout> </textblock> this implemented app.
Comments
Post a Comment