Tooltip showing Legend , Label, XData YData
Using a StackColumn a want to show a tooltip with the above elements: The legend, the label and the X and YData. . Everytging is working except the label. My data template is the above:
DataTemplate template = new DataTemplate();
FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border));
border.SetValue(Border.BackgroundProperty, Brushes.WhiteSmoke);
border.SetValue(Border.CornerRadiusProperty, new CornerRadius(5, 5, 5, 5));
border.SetValue(Border.PaddingProperty, new Thickness(3.0));
border.SetValue(Border.BorderBrushProperty, Brushes.LightGray);
border.SetValue(Border.BorderThicknessProperty, new Thickness(2.0));
FrameworkElementFactory stackpanelVertical = new FrameworkElementFactory(typeof(StackPanel));
stackpanelVertical.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
FrameworkElementFactory stackpanelLegend = new FrameworkElementFactory(typeof(StackPanel));
stackpanelLegend.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
FrameworkElementFactory chartLegend = new FrameworkElementFactory(typeof(Syncfusion.UI.Xaml.Charts.ChartLegend));
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.VerticalAlignmentProperty, VerticalAlignment.Center);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.VerticalContentAlignmentProperty, VerticalAlignment.Center);
Binding chartLegendBinding = new Binding();
chartLegendBinding.Path = new PropertyPath("Interior");
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.BackgroundProperty, chartLegendBinding);
FrameworkElementFactory txtblockLabel = new FrameworkElementFactory(typeof(TextBlock));
txtblockLabel.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockLabel.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockLabel.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockLabel.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding label = new Binding();
label.Path = new PropertyPath("Label");
label.Converter = new LegendValueConverter();
txtblockLabel.SetValue(TextBlock.TextProperty, label);
FrameworkElementFactory stackpanelValues = new FrameworkElementFactory(typeof(StackPanel));
stackpanelValues.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
FrameworkElementFactory txtblockX = new FrameworkElementFactory(typeof(TextBlock));
txtblockX.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockX.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockX.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockX.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding XDataBinding = new Binding();
XDataBinding.Path = new PropertyPath("Item");
XDataBinding.Converter = new ValueConverter();
txtblockX.SetValue(TextBlock.TextProperty, XDataBinding);
FrameworkElementFactory txtblockSeperator = new FrameworkElementFactory(typeof(TextBlock));
txtblockSeperator.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockSeperator.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockSeperator.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockSeperator.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
txtblockSeperator.SetValue(TextBlock.TextProperty, ":");
FrameworkElementFactory txtblockY = new FrameworkElementFactory(typeof(TextBlock));
txtblockY.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockY.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockY.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockY.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding YDataBinding = new Binding();
YDataBinding.Path = new PropertyPath("YData");
YDataBinding.StringFormat = NumberFormat;
txtblockY.SetValue(TextBlock.TextProperty, YDataBinding);
stackpanelLegend.AppendChild(chartLegend);
stackpanelLegend.AppendChild(txtblockLabel);
stackpanelValues.AppendChild(txtblockX);
stackpanelValues.AppendChild(txtblockSeperator);
stackpanelValues.AppendChild(txtblockY);
stackpanelVertical.AppendChild(stackpanelLegend);
stackpanelVertical.AppendChild(stackpanelValues);
border.AppendChild(stackpanelVertical);
template.VisualTree = border;
return template;
Any help?
Thanks
George
DataTemplate template = new DataTemplate();
FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border));
border.SetValue(Border.BackgroundProperty, Brushes.WhiteSmoke);
border.SetValue(Border.CornerRadiusProperty, new CornerRadius(5, 5, 5, 5));
border.SetValue(Border.PaddingProperty, new Thickness(3.0));
border.SetValue(Border.BorderBrushProperty, Brushes.LightGray);
border.SetValue(Border.BorderThicknessProperty, new Thickness(2.0));
FrameworkElementFactory stackpanelVertical = new FrameworkElementFactory(typeof(StackPanel));
stackpanelVertical.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
FrameworkElementFactory stackpanelLegend = new FrameworkElementFactory(typeof(StackPanel));
stackpanelLegend.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
FrameworkElementFactory chartLegend = new FrameworkElementFactory(typeof(Syncfusion.UI.Xaml.Charts.ChartLegend));
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.VerticalAlignmentProperty, VerticalAlignment.Center);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch);
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.VerticalContentAlignmentProperty, VerticalAlignment.Center);
Binding chartLegendBinding = new Binding();
chartLegendBinding.Path = new PropertyPath("Interior");
chartLegend.SetValue(Syncfusion.UI.Xaml.Charts.ChartLegend.BackgroundProperty, chartLegendBinding);
FrameworkElementFactory txtblockLabel = new FrameworkElementFactory(typeof(TextBlock));
txtblockLabel.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockLabel.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockLabel.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockLabel.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding label = new Binding();
label.Path = new PropertyPath("Label");
label.Converter = new LegendValueConverter();
txtblockLabel.SetValue(TextBlock.TextProperty, label);
FrameworkElementFactory stackpanelValues = new FrameworkElementFactory(typeof(StackPanel));
stackpanelValues.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
FrameworkElementFactory txtblockX = new FrameworkElementFactory(typeof(TextBlock));
txtblockX.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockX.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockX.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockX.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding XDataBinding = new Binding();
XDataBinding.Path = new PropertyPath("Item");
XDataBinding.Converter = new ValueConverter();
txtblockX.SetValue(TextBlock.TextProperty, XDataBinding);
FrameworkElementFactory txtblockSeperator = new FrameworkElementFactory(typeof(TextBlock));
txtblockSeperator.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockSeperator.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockSeperator.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockSeperator.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
txtblockSeperator.SetValue(TextBlock.TextProperty, ":");
FrameworkElementFactory txtblockY = new FrameworkElementFactory(typeof(TextBlock));
txtblockY.SetValue(TextBlock.FontSizeProperty, 12.0);
txtblockY.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblockY.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
txtblockY.SetValue(TextBlock.ForegroundProperty, Brushes.Black);
Binding YDataBinding = new Binding();
YDataBinding.Path = new PropertyPath("YData");
YDataBinding.StringFormat = NumberFormat;
txtblockY.SetValue(TextBlock.TextProperty, YDataBinding);
stackpanelLegend.AppendChild(chartLegend);
stackpanelLegend.AppendChild(txtblockLabel);
stackpanelValues.AppendChild(txtblockX);
stackpanelValues.AppendChild(txtblockSeperator);
stackpanelValues.AppendChild(txtblockY);
stackpanelVertical.AppendChild(stackpanelLegend);
stackpanelVertical.AppendChild(stackpanelValues);
border.AppendChild(stackpanelVertical);
template.VisualTree = border;
return template;
Any help?
Thanks
George
SIGN IN To post a reply.
3 Replies
SJ
Sumathi Jayaraj
Syncfusion Team
April 1, 2015 05:40 PM UTC
Hi George,
Thank you for contacting our Syncfusion support.
I have analyzed your requirement and you can get the “Label” of the series in the converter as specified in the below code snippet.
publicclassLegendValueConverter:IValueConverter
{
publicobjectConvert(objectvalue,TypetargetType,objectparameter,System.Globalization.CultureInfoculture)
{
return(valueasChartSegment).Series.Label;
}
}
We have prepared a sample based on your requirements. Please find the sample in the following attachment.
WPFSample.zip
Please let us know if you have any queries.
Regards,
Sumathi J
Thank you for contacting our Syncfusion support.
I have analyzed your requirement and you can get the “Label” of the series in the converter as specified in the below code snippet.
publicclassLegendValueConverter:IValueConverter
{
publicobjectConvert(objectvalue,TypetargetType,objectparameter,System.Globalization.CultureInfoculture)
{
return(valueasChartSegment).Series.Label;
}
}
We have prepared a sample based on your requirements. Please find the sample in the following attachment.
WPFSample.zip
Please let us know if you have any queries.
Regards,
Sumathi J
GS
George Sterg
April 1, 2015 07:35 PM UTC
That works perfect! Thanks!
SJ
Sumathi Jayaraj
Syncfusion Team
April 2, 2015 05:08 AM UTC
Hi George,
Thanks for the update. Please let us know if you require further assistance on this.
Regards,
Sumathi J
Thanks for the update. Please let us know if you require further assistance on this.
Regards,
Sumathi J
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
GS George Sterg
- Mar 31, 2015 08:03 PM UTC
- Apr 2, 2015 05:08 AM UTC