Select to view content in your preferred language

Modify text supplied by DictionaryConverter

639
2
06-11-2010 12:47 AM
ElliottCarson
Occasional Contributor
Hi,

I'm using the ESRI's example of displaying MapTips and this is working fin. My question is how do you then modify the string that is passed back. At the moment the code below shows a Date string "12/03/2010 12:00AM", i would like to show only "12/03/2010". Can I modify this in xaml directly and if so how, or does this need to be done in vb?

....
....
<esri:FeatureLayer.OutFields>
   <sys:String>DATE_</sys:String>
</esri:FeatureLayer.OutFields>
<esri:FeatureLayer.MapTip>
  <Border CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" Margin="0,0,15,15">
    <Border.Background>
      <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">
        <GradientStop Color="#FFD1DFF2"/>
        <GradientStop Color="#FF0088FF" Offset="0.946"/>
      </LinearGradientBrush>
    </Border.Background>
    <Border.Effect>
      <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />
    </Border.Effect>
    <StackPanel Margin="7">
      <TextBlock Text="{Binding Converter={StaticResource MyDictionaryConverter},
                 ConverterParameter=DATE_, Mode=OneWay}" FontWeight="Bold" Foreground="Black"  />
    </StackPanel>
   </Border>
</esri:FeatureLayer.MapTip>
....
....

Thanks for any suggestions,
Elliott
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
If, by chance, you are using Silverlight 4, you could use the new binding  StringFormat property.
Furthermore with SL4, the dictionary converter is no longer useful, so your code could be simplify to:
<TextBlock Text="{Binding [DATE_],StringFormat='dd/MM/yyyy', Mode=OneWay}" FontWeight="Bold" Foreground="Black" />


If you are not using SL4 (and don't want to migrate:)), one option is you to write your own DateDictionary Converter which would return the date with the expected format.
0 Kudos
ElliottCarson
Occasional Contributor
Below is a link to a form on how to implement a IValueConverter for those that are still using sl3. Hope it helps.

http://forums.silverlight.net/forums/p/186984/429605.aspx#429605
0 Kudos