WPF How to put new data in some row in ListView under old data -


i have trouble listview not know do. create gridview inside listview , have ajust data in listview,

what have write new data information in existing row

new data have in same row, color have different , new data have undern old data. old data not change, 2 column , 4 column data crossed

my xaml:

 <listview x:name="lbpersonlist" margin="30,98.4,362,150" scrollviewer.verticalscrollbarvisibility="visible"                 alternationcount="2" >         <listview.view>             <gridview>                 <gridviewcolumn>                     <gridviewcolumnheader content="product">                      </gridviewcolumnheader>                     <gridviewcolumn.celltemplate>                         <datatemplate>                             <textblock text="{binding name}" fontsize="18px" fontfamily="arial"                                         fontweight="normal" width="670" textalignment="left"/>                         </datatemplate>                     </gridviewcolumn.celltemplate>                 </gridviewcolumn>                 <gridviewcolumn >                     <gridviewcolumnheader content="unit price, €"                          horizontalalignment="right">                     </gridviewcolumnheader>                     <gridviewcolumn.celltemplate>                         <datatemplate>                             <textblock text="{binding age}" fontsize="18px"  fontfamily="arial"                                         fontweight="normal"  width="100" textalignment="right"/>                         </datatemplate>                     </gridviewcolumn.celltemplate>                 </gridviewcolumn>                 <gridviewcolumn >                     <gridviewcolumnheader content="quantity"                          horizontalalignment="center">                     </gridviewcolumnheader>                     <gridviewcolumn.celltemplate>                         <datatemplate>                             <textblock text="{binding country}" fontsize="18px"  fontfamily="arial"                                         fontweight="normal"  width="130" textalignment="center"/>                         </datatemplate>                     </gridviewcolumn.celltemplate>                 </gridviewcolumn>                 <gridviewcolumn >                     <gridviewcolumnheader content="price, €"                          horizontalalignment="right">                     </gridviewcolumnheader>                     <gridviewcolumn.celltemplate>                         <datatemplate>                             <textblock text="{binding adress}" fontsize="18px" fontfamily="arial"                                         fontweight="bold"  width="100" textalignment="right"/>                         </datatemplate>                     </gridviewcolumn.celltemplate>                 </gridviewcolumn>             </gridview>         </listview.view>     </listview> 

.cs code:

 public class person {     public string name { get; set; }     public double age { get; set; }     public string country { get; set; }     public double adress { get; set; }    // public bool isdiscount { get; set; }    // public string discountext { get; set; }    // public double discount { get; set; } }  public partial class mainwindow : window {     observablecollection<person> mylist;      public mainwindow()     {         initializecomponent();         mylist = new observablecollection<person>()         {             new person{ name="name 1", age=234444, country="india", adress=1.01},             new person{ name="name 2", age=24, country="india1", adress=12.45},             new person{ name="name 3", age=25, country="india2", adress=45.84},             new person{ name="name 4", age=26, country="india3", adress=12},             new person{ name="name 5", age=27, country="india4", adress=41.21},             new person{ name="name 6", age=28, country="india5", adress=15},             new person{ name="name 7", age=29, country="india6", adress=8},             new person{ name="name 8", age=30, country="india7", adress=9.11},             new person{ name="name 9", age=31, country="india8", adress=7.99},             new person{ name="name 10", age=32, country="india9", adress=18},             new person{ name="name 11", age=33, country="india10", adress=74},             new person{ name="name 12", age=34, country="india11", adress=78.21},             new person{ name="name 13", age=35, country="india12", adress=101.01},             new person{ name="name 14", age=36, country="india13", adress=7},             new person{ name="name 15", age=37, country="india14", adress=9},             new person{ name="name 16", age=38, country="india15", adress=12.15},             new person{ name="name 17", age=39, country="india16", adress=0.14},             new person{ name="name 18", age=40, country="india17", adress=0.99},             new person{ name="name 19", age=41, country="india18", adress=98},             new person{ name="name 20", age=42, country="india19", adress=47},             new person{ name="name 21", age=43, country="india21", adress=1.99},             new person{ name="name 22", age=44, country="india21", adress=1.90},         };         lbpersonlist.itemssource = mylist;       } } 

===============================================

edit: want:

 <gridviewcolumn>                          <gridviewcolumnheader content="product">                          </gridviewcolumnheader>                         <gridviewcolumn.celltemplate>                             <datatemplate>                             <stackpanel orientation="vertical">                                 <grid>                                     <textblock text="{binding odd}"  fontsize="18px" fontfamily="arial"                                         fontweight="normal" width="670" textalignment="left"/>                                 </grid>                                 <textblock  foreground="#b30c0c" fontfamily="arial" fontweight="normal" fontsize="18px" text="{binding discountext}" visibility="{binding isdiscount, converter={staticresource visibilityconverter}}" />                             </stackpanel>                              </datatemplate>                         </gridviewcolumn.celltemplate>                     </gridviewcolumn>                     <gridviewcolumn >     list<mydata> sampledata = new list<mydata>       {          new mydata{odd="name 1", unitprice=455.45, quantity ="india1", price=41.25,               isdiscount=false, discountext="surname 1", discountunit=186, discountprice=1.01},          new mydata{odd="name 2", unitprice=41.87, quantity ="india2", price=47.56,              isdiscount=false, discountext="surname 2", discountunit=84, discountprice=12.45},          new mydata{odd="name 3", unitprice=234, quantity ="india3", price=1.01,              isdiscount=false, discountext="surname 3", discountunit=2744, discountprice=45.84},          new mydata{odd="name 4", unitprice=2.45, quantity ="india4", price=1.04,              isdiscount=false, discountext="surname 4", discountunit=852, discountprice=12},... 

also use public class visibilityconverter : ivalueconverter

i'm not going write thing you, seems pretty straight forward

<stackpanel orientation="vertical">     <grid>        <textblock text="{binding row1} verticalalignment="center" />        <rectangle height="1" fill="red" verticalalignment="center" visibility={binding row2visibility} />     </grid>     <textblock foreground="red" text="{binding row2} visibility={binding row2visibility} /> </stackpanel> 

that's 5 second mock of i'd :). vertical stack panel contains first row , second row of text. 2nd row of text has visibility tied it... 1st row, put inside of grid easy strike through line. if want strike through "right" way, entail cloning system font , adding strike through... when strike through line, no biggie. strike through line visibility same visibility 2nd row of text obviously. either both visible or both collapsed.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -