This is a migrated thread and some comments may be shown as answers.

how to get a hold of MapShape items

1 Answer 55 Views
Map
This is a migrated thread and some comments may be shown as answers.
TMLP
Top achievements
Rank 1
TMLP asked on 16 Aug 2011, 01:11 AM
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);
                     
                }
            }
        }
    }
}

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 18 Aug 2011, 12:46 PM
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 >>

Tags
Map
Asked by
TMLP
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or