Select to view content in your preferred language

time slider displaying values from a field?

1206
4
10-03-2012 12:01 PM
DanielSchatt
Regular Contributor
I have a time slider and I'd like to display certain values in a text block as the time slider moves.  Each value is associated with a time stamp on the time slider.  So I've added a field to the mosaic dataset table associated with the time slider, and added the appropriate values within it.  But I'm not quite sure what the syntax is for binding this with the time slider.  I've been playing with the code below, which just displays the year of the time slider:

         
<StackPanel DataContext="{Binding ElementName=CurrentTimeSlider, Path=Value}" Orientation="Horizontal" Margin="5" HorizontalAlignment="Center">
                <TextBlock Text="{Binding End.Year}" FontSize="12" />
</StackPanel>


The Text that I want to display is within the TextBlock - does anyone know the syntax for what I set the Text equal to?  Do I need to change the DataContext as well?  Is this kind of binding even possible?  Thanks much, appreciate any help..

Dan
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
You can format the string in your binding statement.
Something like:

Text="{Binding End, StringFormat='{}{0:yyyy}'"


You can also do it by code for adjusting the format to the most significative format.
I did it it this sample .
0 Kudos
DanielSchatt
Regular Contributor
thanks much Dominique, I don't know if I made myself clear, sorry.  I'm just not sure how to bind the time slider to another field that I've added in my mosaic dataset table in order to display the field's values.  How do I specify that particular field?  Quite honestly, I'm really in the dark here and I don't even understand what this "End" refers to in the Binding or how to use it.

So, for example, I have a raster "2020" that represents conditions in the year 2020 and which is one of the rasters displayed by the time slider.  That raster is one of the rasters in the mosaic dataset (and therefore the image service built from the mosaic dataset) that the time slider is based on.  I have added an integer field "Test" to the mosaic dataset table.  The "2020" raster has a "Test" value associated with it.  I'd like to display that "Test" value in a text block when the time slider displays the 2020 time, i.e. the 2020 raster. 

Do I type "{Binding End.Test}"?  Or "{Binding Test}"?  Or "{Binding [Test]}"?  etc. I've tried all these and they don't work.

I hope this clarifies, thanks so much for any tips...

Dan
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Dan,

I have no direct answer to your quetion but I can just explain some points you highlighted:

I'm really in the dark here and I don't even understand what this "End" refers to in the Binding or how to use it.


DataContext="{Binding ElementName=CurrentTimeSlider, Path=Value}"


The datacontext of your stack panel is set to the 'Value' property of the TimeSlider.
This property is documented here.
As you can see in the doc, this property is of type TimeExtent which has 2 properties of type DateTime: Start and End.

So that explains why a binding such as <TextBlock Text="{Binding End}" FontSize="12" /> works and displays the end time of the timeslider current position (if your time slider is in 'Instant Mode' the start time will always be equal to the end time).

That explains also your result:
Do I type "{Binding End.Test}"? Or "{Binding Test}"? Or "{Binding [Test]}"? etc. I've tried all these and they don't work.

You can't change that easily the existing types : TimeExtent and DateTime 🙂 (though you can change the display format as I explained in my first post)


So if you want to display new properties in the timeslider, one option is to create you own timeslider control subclassing the toolkit timeslider and add in this control the dependency properties you need (as I did in the sample I pointed out)

That being said, in your case, I am not sure you need to subclass the timeslider.
The info you need to display doesn't seem related to the time slider (it's more an info coming from service) and you are trying to display it outside of the timeslider.
So, at first glance, I would say that you could:
- create a dependency property 'Test' in your user control
- set this property with the value coming from your service (tho not sure how since it's depending on your context and I don't know much about mosaic dataset).
- bind a textblock inside your usercontrol to this dependency property


Hope this helps
0 Kudos
DanielSchatt
Regular Contributor
Thanks! Really appreciate the info, obviously this will be more involved than I thought.

Dan
0 Kudos