I've created a user control which contains a combobox populated w/ the names of the layers in my map and a time slider. When the user selects a layer in the combobox, it checks to see if the selected layer is a dynamic layer with a valid timeextent. If so, I try to set the timeslider's min, max and value properties using that layer via bindings. This seems to work (in debug timeControl has valid properties at the end of cbxLayers_SelectionChanged) but when the user changes the date range in the slider, the data on the map do not change to reflect that time period. One thing to note is that the layers in the map are all added when the maps loads, controlled by a parameter passed in. This means I cannot set the binding in the XAML as the map may not contain any layers which support or have a TimeExtent.Anyone see what I'm missing? Thanks, TGXAML
<esri:TimeSlider x:Name="timeControl" Grid.Row="1" TimeMode="TimeExtent"
PlaySpeed="0:0:1.5" Height="20" Width="200"/>
CS
private void cbxLayers_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ArcGISDynamicMapServiceLayer dlyr = null;
ComboBoxItem cbi = ((sender as ComboBox).SelectedValue as ComboBoxItem);
foreach (Layer l in _Map.Layers)
{
if (l.ID.ToLower() == cbi.Content.ToString().ToLower())
{
if (l is ArcGISDynamicMapServiceLayer) // need to add other time enabled layers later..
{
dlyr = l as ArcGISDynamicMapServiceLayer;
}
break;
}
}
// time slider is in a tab control, on a tab called tabTime - hide if layer does not support Time Extent
TabItem tab = tabQueryType.FindName("tabTime") as TabItem;
if (dlyr == null)
{
tab.Visibility = Visibility.Collapsed;
}
else if (dlyr.TimeExtent == null)
{
tab.Visibility = Visibility.Collapsed;
}
else
{
tab.Visibility = Visibility.Visible;
Binding b = new Binding("Layers[" + dlyr.ID + "].TimeExtent.Start");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.MinimumValueProperty, b);
b = new Binding("Layers[" + dlyr.ID + "].TimeExtent.End");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.MaximumValueProperty, b);
b = new Binding("Layers[" + dlyr.ID + "].TimeExtent");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.ValueProperty, b);
List<DateTime> times = new List<DateTime>();
DateTime dt = dlyr.TimeExtent.Start;
while (dt < dlyr.TimeExtent.End)
{
times.Add(dt);
dt = dt.AddDays(7);
}
timeControl.Intervals = times;
}
tabQueryType.SelectedIndex = 0;
}