I would like to create a custom legend for the XamChart.I need the legend to appear as an icon and the legend data will be shown as tool-tip(see attachment) when the mouse is above the icon. Does any one have an example of a similar solution?
Thanks,
Yevgeni
The Example worked fine but on my application the tooltip does not show the legend. It shows the type of the content e.g "System.Windows.Controls,ContentPresenter"
Hello Yevgeni,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I have been looking into your previous reply and it seems that when you use a key for the DataTemplate for the LegendItemTemplate the template is not applied. I also noticed that the ActulaWidth property of the elements in the panel is 0 when use templates for the Legend’s items. I have modified the sample I sent you earlier today in order to calculate the appropriate width and height for the items in the Legend, so they will be visible.
If you require any further clarifications please do not hesitate to ask.
I have created the folowing DataTemplate but when I use it The Tooltip is empty.
>
Legend
="Percent"
="True">
="temp">
="Auto">
="Uniform">
Ellipse
=Fill}"
="11"
="1" />
=Text}"/>
I gave modifyed the ContentPresenter_Loaded Handler to fit the DataTemplate as folowing:
private void ContentPresenter_Loaded(object sender, RoutedEventArgs e)
{
try
//Panel control = (Utilities.GetDescendantFromType(sender as DependencyObject,
// typeof(LegendItemTemplate), false) as FrameworkElement).Parent as Panel;
foreach (UIElement elem in (((ContentPresenter)sender).Content as Panel).Children)
if (elem is FrameworkElement)
FrameworkElement fm = elem as FrameworkElement;
if (maxHeight < fm.ActualHeight)
maxHeight = fm.ActualHeight;
}
if (maxWidth < fm.ActualWidth)
maxWidth = fm.ActualWidth;
(sender
as ContentPresenter).Width = maxWidth;
as ContentPresenter).Height = ((((ContentPresenter)sender).Content as Panel).Children.Count / 2) * 25;
catch (Exception)
//throw;
Can you help?
<igCA:XamChart.Legend >
<igCA: Legend="Percent" Margin="5,90,70,2" UseDataTemplate="True">
<DataTemplate DataType="{x:Type igCA:LegendItemTemplate}" x:Key="temp">
<Grid Background="{x:Null}" Margin="0,0,0,0" Width="Auto" Height="Auto">
<Viewbox HorizontalAlignment="Left" MaxHeight="20" VerticalAlignment="Stretch" Stretch="Uniform">
<StackPanel Orientation="Horizontal" Width="Auto" Height="Auto"><Grid Width="Auto">
<EllipseFill="{Binding Path=Fill}"Width="11" Height="11" StrokeThickness="1" /></Grid>
<TextBox Text="{Binding Path=Text}" VerticalAlignment="Bottom" HorizontalAlignment="Left"
Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FF4B4B4B"
Margin="3,0,0,0" BorderThickness="0,0,0,0" ToolTip="{Binding Path=Text}"/>
</StackPanel>
</Viewbox>
</Grid>
</DataTemplate>
</igCA:Legend.Resources>
</igCA:Legend>
try{