One way is you to use the LayerItemViewModel 'Tag' property to store your length.
You can initialize the 'Tag' property by code on event legend 'Refreshed' and then just display it with a Binding to Tag.
For more complex scenarios, you can also set the Tag property to a dictionary and use a binding such as {Binding Tag[Length]} (by supposing your dictionary has a 'Length' entry)
Hi thank you for your reply I tried doing it the way you suggested void CustomLegend_Refreshed(object sender, ESRI.ArcGIS.Client.Toolkit.Legend.RefreshedEventArgs e)
{
if (boolRefreshLegend)
{
string[] str = new string[lstRoadSurfaceTypes.SelectedItems.Count];
for (int i = 0; i < lstRoadSurfaceTypes.SelectedItems.Count; i++)
{
KeyValuePair<int, string> ListItemKeyValuePair = (KeyValuePair<int, string>)lstRoadSurfaceTypes.SelectedItems;
str = ListItemKeyValuePair.Value;
}
e.LayerItem.Tag = "52 kms";
var fLayer = e.LayerItem.Layer as FeatureLayer;
if (fLayer != null && fLayer.ID == "Road Surface Type" && e.LayerItem.LegendItems != null)
{
var toRemove = e.LayerItem.LegendItems.Where(item => item.Label != str[0]).ToArray();
int intLegendItemCount = e.LayerItem.LegendItems.Count;
for (int i = 0; i < str.Count(); i++)
{
toRemove = toRemove.Where(item => item.Label != str).ToArray();
}
LegendItemViewModel itemmodel = mainPage.CustomLegend.LayerItems[0];
itemmodel .Tag = "Black Top";
foreach (var item in toRemove)
e.LayerItem.LegendItems.Remove(item);
}
}
}
<esri:Legend.LegendItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal" x:Name="stackpanel1">
<Image Source="{Binding ImageSource}"></Image>
<sdk:Label Content="{Binding Label}" MinWidth="40"/>
<sdk:Label x:Name="label1" Content="{Binding Tag}" MinWidth="40"/>
</StackPanel>
</DataTemplate>
</esri:Legend.LegendItemTemplate>
Please guide me here