WPF Progress bar in ListView remained empty and add new data -
i want implement progressbar
insine listview
:
<listview name="lvtest" itemssource="{binding personlist}" margin="308,45,268,473"> <listview.view> <gridview> <gridviewcolumn width="390" header="file name" displaymemberbinding="{binding name}"/> <gridviewcolumn width="50" header="progress"> <gridviewcolumn.celltemplate> <datatemplate> <progressbar maximum="100" value="{binding progress}"/> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> </gridview> </listview.view> </listview>
my class example:
internal class mydata { public string name { get; set; } public int progress { get; set; } }
and code behind:
var items = new observablecollection<mydata>(); items.add(new mydata() { name = "some", progress = 25 }); items.add(new mydata() { name = "another", progress = 91 }); lvtest.itemssource = items;
and result: http://s12.postimg.org/3mgcwqbvh/image.png
as can see progress bar empty , can see dot inside.
here text in progressbar.
<listview name="lvtest"> <listview.resources> <datatemplate x:key="mydatatemplate"> <grid margin="-6"> <progressbar maximum="100" value="{binding progress}" width="{binding path=width, elementname=progresscell}" height="10" margin="0"/> <textblock text="{binding progress, stringformat={}{0}%}" horizontalalignment="center"/> </grid> </datatemplate> </listview.resources> <listview.view> <gridview> <gridviewcolumn width="390" header="file name" displaymemberbinding="{binding name}"/> <gridviewcolumn x:name="progresscell" width="50" header="progress" celltemplate="{staticresource mydatatemplate}" /> </gridview> </listview.view> </listview>
Comments
Post a Comment