c# - Xaml - Bind listviewitem source object -
i use observablecollecion in vm. collection bind view in listview. in items try element create item. add in commandparameter , thing.
here's vm :
public relaycommand<selectioncommandparameter> cmdremovefromquiz { get; set; } public observablecollection<question> selectedquiz { { return _selectedquiz; } set { _selectedquiz = value; raisepropertychanged("selectedquiz"); } } private void removefromquiz(selectioncommandparameter selection) { if (selection.parameter question) { observablecollection<question> tempquiz = selectedquiz; question _question = (question)selection.parameter; tempquiz.remove(_question); selectedquiz = tempquiz; } }
the problem start removebtn
start command, , selection
stay null
want observablecollection<question>
object use in listviewitem
now view :
<usercontrols:charmflyout x:name="cfoquizlist" x:uid="quizlistcreatingpageflyout" heading="question multiple" horizontalalignment="left" grid.column="0" grid.rowspan="2" style="{staticresource stladdrecipientflyout}"> <tut:tutorialawarelistview x:name="gvquizitem" itemssource="{binding selectedquiz}" isitemclickenabled="true" canreorderitems="true" selectionmode="none" manipulationmode="translaterailsx"> <listview.itemtemplate> <datatemplate x:name="dtquizitem"> <grid horizontalalignment="left" width="{staticresource rectangletilewidth}" height="{staticresource rectangletileheight}" margin="0 0 0 0" background="{staticresource orangebackgroundthemebrush}"> <grid grid.column="1"> <button x:name="removebtn" content="x" horizontalalignment="right" verticalalignment="top" width="40" height="40" borderthickness="0" command="{binding datacontext.cmdremovefromquiz, elementname=gvquizitem}" commandparameter="{binding question}"/> <maxctrls:maxautoscrollingcontentpresenter verticalalignment="center" scrollingduration="{binding name, converter={staticresource texttotimetoreadshortformatconverter}}" scrollingbegintime="0:0:2"> <textblock text="{binding name}" fontweight="semibold" foreground="{staticresource whitebackground}" margin="20,5,10,5" verticalalignment="center" textwrapping="wrap"/> </maxctrls:maxautoscrollingcontentpresenter> </grid> </grid> </datatemplate> </listview.itemtemplate> </tut:tutorialawarelistview> </usercontrols:charmflyout>
the tutorialawarelistview work listview. use juste point element while tutorial running.
it's windows store app !! can't thing to.
you should change selectionmode="none" single or multiply. , make new observablecollection selected items. bind itemssource="{binding selectedquiz}". bind selecteditems="{...}"
Comments
Post a Comment