Select to view content in your preferred language

time slider issues

847
2
08-21-2012 06:32 AM
DanielSchatt
Regular Contributor
hi, I'm having some trouble getting a time slider to work.  I'm trying to create a very simple time slider with 5 rasters having the same map extent, representing conditions in 5 different years (2020, 2040, 2060, 2080, 2100).  Just want a time slider with 20 year intervals (i.e. beginning and end with 3 tic marks in between) displaying those rasters for those 5 years. 

So I followed the basic steps: created TIF images and added them to a mosaic dataset, added a date type field to the mosaic dataset and put in the dates, time-enabled it and set the start time field in ArcCatalog.  Then I published an image service from that.  When I run the application, I see a time slider with the proper time extent but there are no play/forward/backward buttons and no tic marks; the thumb can be placed anywhere on the timeline and rasters only display when I place it at the beginning or end of the timeline.  It seems there's something wrong with the code-behind that has the intervals information.  Really appreciate any tips..

My XAML come straight from the sample:

<!-- TIME SLIDER (from sample Time Slider) -->
        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" >
            <Rectangle Fill="#77919191" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Border Background="#FFFFFFFF" BorderBrush="DarkGray" CornerRadius="5" Margin="10,10,10,15"
                    Width="250" HorizontalAlignment="Center" VerticalAlignment="Top" >
                <StackPanel Margin="5">
                    <StackPanel HorizontalAlignment="Center">
                        <TextBlock HorizontalAlignment="Center" FontSize="16" Text="Sea Level Rise" />
                    </StackPanel>                    
                    <StackPanel DataContext="{Binding ElementName=MyTimeSlider, Path=Value}" 
                            Orientation="Horizontal" Margin="5" HorizontalAlignment="Center">
                    </StackPanel>
                    <esri:TimeSlider x:Name="MyTimeSlider"
                        Loaded="MyTimeSlider_Loaded"
                        TimeMode="TimeInstant"
   Height="20"
                        MinimumValue="{Binding ElementName=SeaLevelRiseMap, Path=Layers[9].TimeExtent.Start, Mode=OneWay}" 
   MaximumValue="{Binding ElementName=SeaLevelRiseMap, Path=Layers[9].TimeExtent.End, Mode=OneWay}" 
   Value="{Binding ElementName=SeaLevelRiseMap, Path=Layers[9].TimeExtent, Mode=OneWay}">    
      </esri:TimeSlider>
                </StackPanel>
            </Border>
        </Grid>


And my code-behind:

        private void MyTimeSlider_Loaded(object sender, System.Windows.RoutedEventArgs e)
                  {
   List<DateTime> intervals = new List<DateTime>();
   DateTime dt = MyTimeSlider.MinimumValue;
   while (dt < MyTimeSlider.MaximumValue)
   {
       intervals.Add(dt);
       dt = dt.AddYears(20);
   }
   MyTimeSlider.Intervals = intervals;
                  }


Thanks much for any help...

Dan
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Try with a slider in TimeExtent mode

TimeMode="TimeExtent"

Your service might not support well exact time value.
0 Kudos
DanielSchatt
Regular Contributor
thanks Dominique, I managed to finally resolve this by putting in explicit date values for MinimumValue, MaximumValue, and Value, i.e. "1/1/2020".  For some reason it wasn't resolving those expressions that were there before.  I don't know if this is the most elegant solution but it works.
0 Kudos