1

How can I show "No records found" when there are no data in itemsource bound to a Listbox. If I add a new textbox it gives an exception as cannot add data to readonly collection.

Thanks and Regards, Kanaya

Kenny
  • 819
  • 1
  • 9
  • 24

3 Answers3

3

You can have a Grid with a TextBox and the ListBox in front, if the ListBox has content it will hide the TextBox and/or Bind the Visbility to the Count property of your ObervableCollection with a converter.

MatthieuGD
  • 4,552
  • 2
  • 30
  • 29
1

instead of doing this. check the count and hide the listbox if there are zero records and show a textblock with the message.

Hermit Dave
  • 3,036
  • 1
  • 13
  • 13
1

how are you binding data to the source of the listbox? If its by databinding with a property in its viewmodel, then simply check that property for null or empty . This will serve the purpose.

Providing more info or code you are using can bring in more help.

TutuGeorge
  • 1,972
  • 2
  • 22
  • 42