Use of ItemsRequestEventArgs

2 posts, 0 answers
  1. Manfred
    Manfred avatar
    53 posts
    Member since:
    Jan 2011

    Posted 27 Jan 2011 Link to this post


    I am just new to this kind of coding and I have one question:
    the example for adding dynamic layer is just the old version, so it doesn't show the use of ItemsRequestEventArgs.

    Can you guys give me a hint how to use that in my code?
    I added the class MapDynamicSource and modified ItemsRequest to
    public void ItemsRequest(object sender, ItemsRequestEventArgs e)

    But I have no idea how to call that.

    Best regards
  2. Andrey
    Andrey avatar
    1681 posts

    Posted 01 Feb 2011 Link to this post

    Hi Manfred,

    The dynamic layer was redesigned in 2010.Q3 version. You can look at our online example which uses the new ItemsRequest functionality.

    The ItemsRequestEventArgs contains all parameters which are required for requesting items. For example you have the following ItemsRequest which was designed for Q2 and new one:

    public class DynamicSource : IMapDynamicSource 
        public void ItemsRequest(double minZoom, double maxZoom, Telerik.Windows.Controls.Map.Location upperLeft, Telerik.Windows.Controls.Map.Location lowerRight, Action<System.Collections.ICollection> callback)
            // ...
        public void ItemsRequest(object sender, ItemsRequestEventArgs e) 

    The parameters of the old ItemsRequest method could be obtained from the ItemsRequestEventArgs instance in the new request as the following way:
        minZoom = e.MinZoom
        maxZoom = e.MaxZoom
        upperLeft = e.UpperLeft
        lowerRight = e.LowerRight
    Also the ItemsRequestEventArgs contains the CompleteItemsRequest method which you should use instead of the callback.

    As a simple migration way you can change the code of dynamic source class to use a code which was designed for Q2 just using new delegate type instead of Action<System.Collections.ICollection> for callback. The sample code is below.

    public class DynamicSource : IMapDynamicSource 
        // … 
        public delegate void CallbackDelegate(IEnumerable<object> items); 
        public void ItemsRequest(object sender, ItemsRequestEventArgs e) 
            this.ItemsRequest(e.MinZoom, e.MaxZoom, e.UpperLeft, e.LowerRight, e.CompleteItemsRequest); 
        // Q2 style items request 
        public void ItemsRequest(double minZoom, double maxZoom, Location upperLeft, Location lowerRight, CallbackDelegate callback) 
            List<object> objects = new List<object>(); 
            // … 

    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
Back to Top