Select to view content in your preferred language

bind FeatureLayer to other controls

670
3
09-29-2010 09:45 AM
DaveOrlando
Frequent Contributor
Hello, looking for some guidance,

I have a FeatureLayer and MapTips working fine. The MapTips are a 'mini' report of only a few attributes with a button to open a 'full' report.
I have been able to bind items (textblocks) from the mini into the full, but obviously they would have to exist in the mini first.
I would rather bind my full report directly to the FeatureLayer. Can this be done straight from the xaml, or would I have to, on the button click make an event to dump the results to something, then bind to that? I have set the DataContext of the full report to the FeatureLayer but no results come across.

Thanks in advance.
0 Kudos
3 Replies
DaveOrlando
Frequent Contributor
...some progress

from the button click on the MapTip I am executing a query to return all the attributes of that feature to then bind into a full report, as outlined above. For now the query where clause is hardcoded because I'm having trouble pulling any attribute (textbox) from my maptip into code behind.

kind of a rookie questions, but how can I access one of the maptip's attributes in code to then run the query.
I have tried:
string str = MapTipTitle.Text.ToString(); thinking that I could access it directly but no go.
0 Kudos
DaveOrlando
Frequent Contributor
for those who are interested........

private void btnOpenReport_Click(object sender, RoutedEventArgs e)
        {
            QueryTask queryFL = new QueryTask("http://xxx/MapServer/29");
            queryFL.ExecuteCompleted += new EventHandler<QueryEventArgs>(queryFL_ExecuteCompleted);
            queryFL.Failed += new EventHandler<TaskFailedEventArgs>(queryFL_Failed);
            
            FeatureLayer tmpFL = MyMap.Layers["FLParcels"] as FeatureLayer;     // ! ID, not x:Name !
            TextBlock tmp = tmpFL.MapTip.FindName("MapTipTitle") as TextBlock;
            String strFolio = tmp.Text.ToString();

            Query query = new Query();
            query.OutFields.Add("*");
            query.Where = "folio = " + strFolio;
            queryFL.ExecuteAsync(query);

            bool bVisible = slPanel.IsVisible;
            if (bVisible)
                slPanel.Visibility = Visibility.Collapsed;
            else
            {
                slPanel.Visibility = Visibility.Visible;
            }            
        }

        void queryFL_Failed(object sender, TaskFailedEventArgs e)
        {
            //throw new NotImplementedException();
            MessageBox.Show("Query failed: " + e.Error);
        }

        void queryFL_ExecuteCompleted(object sender, QueryEventArgs e)
        {
            //throw new NotImplementedException();

            FeatureSet FSresult = e.FeatureSet; 
            
            // target in full report
            textBox1.Text = FSresult.Features[0].Attributes["street_nam"].ToString();            
        }
0 Kudos
by Anonymous User
Not applicable
in XAML your button

<Button Tag="{Binding [YourAttribute]}" ..../>


in Code Behide Button_Click

Button button = sender as Button;
string attribute = button.Tag.ToString();


Use Button.Tag you can bring anything to CodeBehide.
0 Kudos