xmlns:bing="clr-namespace:ESRI.ArcGIS.Client.Bing;assembly=ESRI.ArcGIS.Client.Bing" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <esri:Map x:Name="MyMap"> <bing:TileLayer ID="BingLayer" LayerStyle="Aerial" ServerType="Production" Token="{StaticResource BingKey}"/> </esri:Map> <ComboBox x:Name="BingLayerStyle" SelectionChanged="BingLayerStyle_SelectionChanged" SelectedItem="{Binding ElementName=MyMap, Path=Layers[BingLayer].LayerStyle, Mode=TwoWay}" VerticalAlignment="Top" HorizontalAlignment="Center"/> </Grid>
BingLayerStyle.ItemsSource = new ESRI.ArcGIS.Client.Bing.TileLayer.LayerType[]{ ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.Aerial, ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.AerialWithLabels, ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.Road}; BingLayerStyle.SelectedIndex = 1;
public class MainPageViewModel : ViewModelBase { private TileLayer.LayerType _newLayerType; public RelayCommand UpdateBackgroundCommand { get; private set; } public MainPageViewModel() { _newLayerType = TileLayer.LayerType.AerialWithLabels; WireCommands(); } private void WireCommands() { UpdateBackgroundCommand = new RelayCommand(UpdateBackground); UpdateBackgroundCommand.IsEnabled = true; } #region Properties public TileLayer.LayerType NewLayerType { get { return _newLayerType; } set { if (_newLayerType != value) { _newLayerType = value; OnPropertyChanged("NewLayerType"); } } } #endregion public void UpdateBackground(object param) { switch(param.ToString()) { case "Road": _newLayerType = TileLayer.LayerType.Road; MessageBox.Show(_newLayerType.ToString()); break; case "Aerial": _newLayerType = TileLayer.LayerType.Aerial; MessageBox.Show(_newLayerType.ToString()); break; case "AerialWithLabels": _newLayerType = TileLayer.LayerType.AerialWithLabels; MessageBox.Show(_newLayerType.ToString()); break; } } }
public class ViewModelBase : INotifyPropertyChanged { public bool IsDesignTime { get { return DesignerProperties.IsInDesignTool; } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propName) { var propChanged = PropertyChanged; if (propChanged != null) { propChanged(this, new PropertyChangedEventArgs(propName)); } } #endregion }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.