Select to view content in your preferred language

FeatureLayer URL property Binding

512
4
08-19-2011 05:40 AM
JustinCornell
Occasional Contributor
Has anyone had success binding to the featureLayers Url property with the silverlight version 2.2 api?  I can't get it to work.  I believe this is a bug.  Anyone have any advice?

Here is my xaml and the sample code:
<UserControl x:Class="FeatureLayerBindingTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <esri:Map>
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer Url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
                <esri:FeatureLayer Url="{Binding FeatureLayerURL}"/>
            </esri:Map.Layers>
        </esri:Map>
    </Grid>
</UserControl>
using System.Windows.Controls;
using System.ComponentModel;

namespace FeatureLayerBindingTest{
    public partial class MainPage : UserControl{
  public string FeatureLayerURL { 
            get { return "http://okcgisprd200/ArcGIS/rest/services/Systems/Dynamic_UIM/MapServer/1"; }
  }
    
        public MainPage(){
            InitializeComponent();
            this.DataContext = this;            
        }
    }
}
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
FeatureLayer.Url is a DependencyProperty which means you can bind to it. However, it cannot be updated once the layer is initialized.
0 Kudos
OrenGal
Regular Contributor
Try this:
1. Erase the URL part from the featurelayer XAML like this:

<esri:FeatureLayer ID="MyFeatureLayer" Where="1=1"  FeatureSymbol="{StaticResource MySymbol}"  />

2. In code behind:

InitializeComponent();
FeatureLayer pFeatureLayer = (FeatureLayer)MyMap.Layers["MyFeatureLayer"];
pFeatureLayer.Url = "http://.............";
0 Kudos
wzm
by
Emerging Contributor
FeatureLayer.Url is a DependencyProperty which means you can bind to it. However, it cannot be updated once the layer is initialized.


But if I want to initialize my featurelayer's Url by binding to a Configued string, is there any solution? Because I want to use the xaml to personalize my featurelayer's maptips/cluster/...,I'm so lazy and donot want to code behind.I tried to build a dependencyproperty and bind url to that but it did not work,I just do not know why featurelayer's url cannot be binded or set before it's initializing event,any advice will be appreciated!!!
0 Kudos
wzm
by
Emerging Contributor
But if I want to initialize my featurelayer's Url by binding to a Configued string, is there any solution? Because I want to use the xaml to personalize my featurelayer's maptips/cluster/...,I'm so lazy and donot want to code behind.I tried to build a dependencyproperty and bind url to that but it did not work,I just do not know why featurelayer's url cannot be binded or set before it's initializing event,any advice will be appreciated!!!



I tried in the map loaded event I can set the url property sometimes,but still failed .
0 Kudos