Get access to listbox on dockpane

895
4
05-18-2020 03:29 PM
helenchu
Occasional Contributor II

Hi,

I'm from ArcMap world and totally confused between MVVM annd WPF and RelayCommand so please help me out.  

In my Dockpane1ViewModel.cs I tried

private void DoSearch ()
{
string strLayerName = "abc";
string queryString= "";
foreach (var item in lslSubjAcct.Items)
{
queryString+= item.ToString() + ", ";
}

SelectByAttributeAsync(strLayerName , queryString);
}

Error: lslSubjAcct does not exist in current context.  How do I fix it?  

Thank you!

0 Kudos
4 Replies
DHuantes
New Contributor III

I'm confused by what you're trying do it.  I get the following:

1.  You have a created a DockPane

2.  On the DockPane you want to "DoSearch" presumably from a button on your dockpane.

3.  I don't know what lslSubjAcct is... Maybe a list box with items to be used in "where clause" for a query?   

4.  SelectByAttributeAsync is maybe a custom method you have?

I think you need to provide a little more explanation of what you're trying to accomplish.

0 Kudos
helenchu
Occasional Contributor II

Hi Daniel,

Sorry for not explaining clearly and thanks for your response.

1/ Yes I created a dockpane

2/ A button on my dockpane to do search and zoom to selection on active map. 

3/  lslSubjAcct is the name of a listbox that stores single or multiple account numbers to search

4/ SelectByAttributeAsync is  a custom method that DoSearch call.

I hard coded my where clause for the query and it works fine.  What I'm trying to accomplish is to get all accounts on my listbox lslSubjAcct.  The queryString (for the codes above) should be '1234','5678',9101'.  Then I'll add FieldNameString, parentheses later.  Final queryString should be Fieldname in ('1234', '5678')

In ArcObject everything is in 1 place, much more simple for me to understand.

Thank you so much.

FredericPoliart_EsriAU
Occasional Contributor II

Hi @helenchu 
Do you know if there is a way to create a ListBox and allow the user to select multiple items, (holding CTRL or SHIFT key) ?

 

0 Kudos
helenchu
Occasional Contributor II

Hi, 

In my case, users select either 1 item or all items.  You can check out the this link for suggestion on how to do multiple selection.  Sorry I couldn't be more helpful.

c# - Selecting multiple Listbox items through code - Stack Overflow

 

0 Kudos