bind Uri StaticResource MapShapeReader

2 posts, 1 answers
  1. Manuel
    Manuel avatar
    1 posts
    Member since:
    May 2012

    Posted 15 May 2012 Link to this post

    I need some help with MapShaperReader: Source and DataSource binding. This is probably easy to answer but I have trouble binding these to static resources that would be updated/changed later at runtime on a button press. I need to pass them the map locations as strings, such as: "DataSources/europe.shp". Both require Uri as type so a IValueConverter i think is needed. 
    XAML:
    <UserControl.Resources>
            <local:MSRResourceWraper x:Key="test"/>
            <local:Users x:Key="user" DataContext1="{Binding TT1, Source={StaticResource test}}" DataContext2="{Binding TT2, Source={StaticResource test}}"/>
        </UserControl.Resources>

    <telerik:InformationLayer Name="wwww">
       <telerik:InformationLayer.Reader>
          <telerik:MapShapeReader Source="{Binding DataContext1, Source={StaticResource user}}"
                DataSource="{Binding DataContext2, Source={StaticResource user}}">
           </telerik:MapShapeReader>
      </telerik:InformationLayer.Reader>
    </telerik:InformationLayer>
    c#
    public class Users
        {
            public Uri DataContext1 { get; set; }   
            public Uri DataContext2 { get; set; }
            public Users()
            {
                //DataContext1 = new Uri("DataSources/africa.shp",UriKind.Relative);
                //DataContext2 = new Uri("DataSources/africa.dbf", UriKind.Relative);
            }
        }
        public class MSRResourceWraper : INotifyPropertyChanged
        {
            private Uri headerColor1 = new Uri("DataSources/africa.shp",UriKind.Relative);
            private Uri headerColor2 = new Uri("DataSources/africa.dbf", UriKind.Relative);
            public Uri TT1
            {
                get
                {
                    return headerColor1;
                }
     
                set
                {
                    headerColor1 = value;
                    OnPropertyChanged("TT");
                }
            }
     
            public Uri TT2
            {
                get
                {
                    return headerColor2;
                }
     
                set
                {
                    headerColor2 = value;
                    OnPropertyChanged("TT");
                }
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string info)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(info));
                }
            }
        }

    The implementation should probably be similar to http://forums.silverlight.net/t/229874.aspx/1 

    Any help is apreciated,
    Thank you!
  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 May 2012 Link to this post

    Hi Manuel,

    Most of our examples use the viewmodel for their shape-files as you required. For example you can take a look at the following examples which use single viewmodel:
    http://demos.telerik.com/silverlight/#Map/Shapefile/Europe
    http://demos.telerik.com/silverlight/#Map/Shapefile/Asia

    This viewmodel contains the Region property you can change to change a source shape-file. I have attached a sample solution which uses this viewmodel and which changes the Region using a button. I hope it helps.

    Greetings,
    Andrey Murzov
    the Telerik team

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

  3. DevCraft banner
Back to Top