4 Replies Latest reply on Jul 31, 2012 7:03 AM by sthambir

    Customized Identify Behavior

    sthambir
      Hi,

      1. I do not want to use the standard Identify behavior in the map web part as I have a need to customize some of the attribute values. First, can someone tell if it is possible to customize the standard identify behavior?

      2. Assuming, I can't do the above, I have created a new behaviour using the IdentifyTask on mouse click. IdentifyTask is returning back the results correctly. But, I want to bring up an info window with these results. I have seen discussions like this in the Silverlight forum but all I want is create the info window entirely on code-behind. With the silver light example on Simple Info Window, I am struggling to understand how to set the content template from code-behind (i.e. in my custom behavior code) without having any reference to the xaml.

      Any pointer on this is much appreciated.

      Thanks!
        • Re: Customized Identify Behavior
          ekallatum
          hi sthambir,

          Have you solved the first problem.
          I tri to add a custom Identify Behavior but I but I unable to show it in a map.
          I understand that we must add OnclickPopupInfo object, PopupItem and Popupinfo, but I dont know use it.

          Thk,
          • Re: Customized Identify Behavior
            sthambir
            hi,

            Yes, I have used InfoWindow which popups on feature mouse click (raised by attaching a mouse click event on the layer). Have used silverlight controls (stackpanel/text block/dock panel,etc) to create the required attribute window which is set as the content of the InfoWindow.

            This InfoWindow's anchor point is set to the mouse clicked position and then the InfoWindow is added to the visual tree to place it on top of the map. All of this is done in code behind and works very well.

            The only drawback is it doesn't bring back attributes of multiple features as the standard identify behaviour, only the top layer feature is returned currently. But, I am sure there should be  a workaround for which I haven't spent time yet.

            Cheers.
            • Re: Customized Identify Behavior
              ekallatum
              Hi,

              Can you send me your behavior?

              Thk,
              • Re: Customized Identify Behavior
                sthambir
                Code snippet below:

                
                
                Capture click event on the layer:
                
                myGraphicsLayer.MouseLeftButtonUp += new GraphicsLayer.MouseButtonEventHandler(myGraphicsLayer_MouseLeftButtonUp);
                 
                void myGraphicsLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
                {
                    InfoWindow infowin;
                    GraphicsLayer gl = (GraphicsLayer)sender as GraphicsLayer;
                
                       TextBlock tb = new TextBlock();
                       tb.Text = "My attribute content";
                       tb.Margin = new Thickness(2);
                       tb.FontSize = 14;
                
                       //set the info window and its content to the text block (whatever control you are using)
                                infowin.Map = myMap;
                                infowin.Anchor = myMap.ScreenToMap(e.GetPosition(myMap));
                                infowin.Content = tb;
                                infowin.IsOpen = true;
                                infowin.Visibility = Visibility.Visible;
                
                       //add infowin to the layout
                       FrameworkElement parent = VisualTreeHelper.GetParent(myMap) as FrameworkElement;
                       ((Grid)parent).Children.Add(infowin);
                }