xaml - WPF ListBox display last item differently -


i want have listbox, allows user fetch lets 20 items db , displays hint on last row of listbox if there more items fetched. when user clicks on last row, additional items should retrieved db, until there aren't more , last line displays information.

first:

listitem1 listitem2 ... listitem19 listitem20 button: <get_more> 

after button press:

listitem1 listitem2 ... listitem39 listitem40 info: <no more items> 

could done in xaml only? best solution implement this?

dude -- everything can done xaml :d

following mvvm approach, i'd recommend following:

1/ getting started: dockpanel

<dockpanel lastchildfill="true">    <button dockpanel.dock="bottom" />    <listbox  /> </dockpanel> 

2/ bind listbox observablecollection in viewmodel:

<listbox itemssource="{binding listelements}" /> 

in viewmodel:

private observablecollection<string> _listelements;          public observablecollection<string> listelements         {             { return _listelements; }             set { _listelements = value; }         } 

3/ bind button's content predefined string:

<button content="{binding buttonstring}" /> 

in viewmodel:

public string buttonstring {        {       //there, define if there more things display    } } 

4/ button fires command launching method, let's getmore() :

<button content="{binding buttonstring}" command="{binding getmorecommand} /> 

in viewmodel:

private void getmore() {    //append _listelements new elements list     //update buttonstring if there no more elements } 

and there go!

(you can also, if needed, define button removing things observablecollection example)


Comments