c# - multiple and single row selection listview with a gridview wpf -
i have question regarding wpf , listview
s. have program code in windows.xaml
<grid> <listview margin="10" name="lvusers"> <listview.view> <gridview> <gridviewcolumn header="names" width="140" displaymemberbinding="{binding name}" /> <gridviewcolumn header="telefon" width="60" displaymemberbinding="{binding age}" /> <gridviewcolumn header="adress" width="180" displaymemberbinding="{binding mail}" /> </gridview> </listview.view> </listview>
and in windows.xaml.cs have code
public partial class listviewgridviewsample : window { public listviewgridviewsample() { initializecomponent(); list<user> items = new list<user>(); items.add(new user() { name = "molo", telefon= 0909090, adress= "street" }); items.add(new user() { name = "moloi", telefon="99999", adress= "street2" }); } }
and question is, when execute program code window listview
. , want make selection @ single or multiple rows. maybe want select row number 2 user moloi , after selecting row want pass on message box example. how can handle that?
can give me easy example pls
thank all
listview has property called selectionmode="extended"
. allow set desired selection mode. make selection behavior, can use selectionchanged
event available on listview
. these 2 things can achieve stated above.
<listview name="lvusers" itemssource="{binding}" margin="10" selectionmode="extended" selectionchanged="lvusers_selectionchanged"> <listview.view>
and code behind event:
private void lvusers_selectionchanged(object sender, selectionchangedeventargs e) { //e.addeditems - these items have been selected }
Comments
Post a Comment