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

bind Uri StaticResource MapShapeReader

1 Answer 70 Views
Map
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 15 May 2012, 12:06 PM
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!

1 Answer, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 18 May 2012, 08:30 AM
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 >>

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