AnsweredAssumed Answered

How to retrieve all items in listbox and put them to a string?

Question asked by helenchu on May 19, 2020
Latest reply on May 21, 2020 by lluong

Hi all,

I have 

<ListBox x:Name="lstAllAcct" Grid.Row="1"  ItemsSource="{Binding ExcelData}"/>

<Button x:Name="btnNewSelection" Command="{Binding Path=NewSelectionCmd}">

 

 

{Binding ExcelData} is to get accounts from excel sheet to my listbox : done

Now when button btnNewSelection is click I want to get all accounts in that listbox to a string (to construct my query statement)

 

The code behind for the button:

 

private RelayCommand _newSelectionCmd;
public ICommand NewSelectionCmd
{
get
{
if (_newSelectionCmd == null)

 

_newSelectionCmd = new RelayCommand(() => DoSearch(), () => true);

return _newSelectionCmd;
}

 

private void DoSearch ()
{

string strAllAccount =""

(how to I get all items in my listbox to strAllAccount?)
}

Your help is very much appreciated.

 

 

Outcomes