Select to view content in your preferred language

Query in Silverlight?

3099
11
01-20-2012 05:27 AM
LauraMellem
Emerging Contributor
I want to add a query tool that does not require the user to type in an sql expression.  Is there a way to list domain values using the tool to make it easier?
0 Kudos
11 Replies
KatherineDalton
Esri Regular Contributor
Hi Katy,
               Am also in the same situation, to create a Custom add-in for the query. Even the sample is available, this is not user fiendly. In the sample we need to type the entire query, with the proper attribute names and field values. But that is not possible at all.

               So, please guide me to read the attribute field names and unique values of attributes from the selected layer. Is therer any build-in function to read those fields and values of the fields?


Hi Ariharan,

This thread actually contains discussion of two different Search-type tools/operations. The Search tool that we have released is designed to search for content on the web, ArcGIS Online, an ArcGIS Server instance, or a place using a custom locator. The type of Search you are referring to where you can input a Query and find records in your data is not yet available. We are working on this latter functionality for our March release.

Hope that helps,
Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
KatherineDalton
Esri Regular Contributor
How to bind a query returns/results to a textblock in XAML?  See below.  Thanks

<TextBlock x:Name="textLabel" Forground="White" Text="Total records/features found: " />
<TextBlock x:Name="featuresFound" Foreground="Red" Text="{Binding ... }" />


Hi Yurong,

We take an Model-View-ViewModel (MVVM) approach with this type of binding, and I've included some code below that should help get you started. This code is from the QueryRelatedRecords tool we will be releasing shortly. Note that you do not need to use a ListBox, but it shows the pattern for binding.


RelationshipSelectionView.xaml:
 <ListBox HorizontalAlignment="Stretch" x:Name="RelationshipsListBox" Background="Transparent" BorderBrush="Transparent" Margin="5,2,-5,0" ItemsSource="{Binding RelationshipList}"
            VerticalAlignment="Stretch" DisplayMemberPath="Name" Width="300" FontFamily="SegoeUI" Grid.Row="2" Grid.ColumnSpan="3">
        </ListBox>


QueryRelatedTool.cs (the tool clicked):

relationshipList = new List<Relationship>();
QueryRelatedViewModel vm = new QueryRelatedViewModel(relationshipList, MapApplication.Current.Map);
RelationshipSelectionView relationshipView = new RelationshipSelectionView();
relationshipView.DataContext = vm;

int relCount = relatesLayer.LayerInfo.Relationships.Count();
            if (relCount > 1) // Layer has more than one relationship
            {
                foreach (Relationship rel in relatesLayer.LayerInfo.Relationships)
                {
                    relationshipList.Add(rel);
                }

            }


QueryRelatedViewModel.cs:

 public QueryRelatedViewModel(List<Relationship> relationships, Map Map)
        {
            RelationshipList = relationships;
            map = Map;
        }

 private List<Relationship> relationshipList;
        /// <summary>
        /// Gets or sets the list of Relationships associated with a layer
        /// </summary>
        public List<Relationship> RelationshipList
        {
            get { return relationshipList; }
            private set
            {
                if (relationshipList != value)
                    relationshipList = value;
            }
        }


Hope that helps,
Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos