how to get a hold of MapShape items

2 posts, 1 answers
  1. TMLP
    TMLP avatar
    38 posts
    Member since:
    Jul 2009

    Posted 15 Aug 2011 Link to this post

    Hi,

    I'm new to silverlight and telerik. I'm trying to display some data that i got from calling a webservice on the tooltip. I can assign the data on tooltip inside function

     

    "Reader_PreviewReadCompleted". However, this function gets called before I get my data from webservice. So, what I am thinking is to get a hold of MapShape items at the end of my webservice call to assign data.. how do i do that..?

    public MainPage()
    {
        InitializeComponent();
     
        ....
        Proxy.ListsSoapClient proxy = new Proxy.ListsSoapClient(basicHttpBinding, endpointAddress);
        proxy.GetListItemsCompleted += new EventHandler<SpProxy.GetListItemsCompletedEventArgs>(proxy_GetListItemsCompleted);
        proxy.GetListItemsAsync(ListGuid, null, query, viewFields, null, queryOptions, null);
    }
    void proxy_GetListItemsCompleted(object sender, SpProxy.GetListItemsCompletedEventArgs e)
    {
            ... // I receive my data inside this function
            myListset.Add(nItem); // I can assign my data to MapShape items at this point..?
        }
    }
    private void MapShapeReader_PreviewReadCompleted(object sender, Telerik.Windows.Controls.Map.PreviewReadShapesCompletedEventArgs eventArgs)
    {
        if (eventArgs.Error == null)
        {
            foreach (MapShape shape in eventArgs.Items)
            {
                ExtendedData extendedData = shape.ExtendedData;
                if (extendedData != null)
                {
                    string countryName = (string)shape.ExtendedData.GetValue("CNTRY_NAME");
                    if (countryName == "United States")
                    {
                        ExtendedPropertySet propertySet = new ExtendedPropertySet();
                        propertySet.RegisterProperty("Data", "Data", typeof(string), string.Empty);
     
                        ExtendedData usaData = new ExtendedData(propertySet);
                        usaData.SetValue("Data", "sample data");
                        shape.ExtendedData = usaData;
     
                        ToolTip tooltip = new ToolTip();
                        Binding tooltipBinding = new Binding()
                        {
                            Converter = new ExtendedDataConverter(),
                            ConverterParameter = "{Data}",
                            Source = shape.ExtendedData
                        };
                        tooltip.SetBinding(ToolTip.ContentProperty, tooltipBinding);
                        ToolTipService.SetToolTip(shape, tooltip);
                         
                    }
                }
            }
        }
    }

     

  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Aug 2011 Link to this post

    Hi Tmlp,

    You can add a field to save the shape list from the PreviewReadCompleted event. You can use it later at the moment when data is retrieved from the web service.
    The sample code is below:

    private List<FrameworkElement> items;
     
    private void MapShapeReader_PreviewReadCompleted(object sender, Telerik.Windows.Controls.Map.PreviewReadShapesCompletedEventArgs eventArgs)
    {
        if (eventArgs.Error == null)
        {
            this.items = eventArgs.Items;
        }
    }

    void proxy_GetListItemsCompleted(object sender, SpProxy.GetListItemsCompletedEventArgs e)
    {
        foreach (MapShape shape in this.items)
        {
            //
        }
    }

    Kind regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
Back to Top