I am using a MarkerDataTemplate. Is there away from the Marker or DataPoint to call FindName to get to a control in my MarkerDataTemplate? I am using ScatterLine chart. It seems Marker is not visual.
Hello,
It is my understanding that FindName does not work with templates. However, you can use the VisualTreeHelper with the Marker to go up and down the tree to find the element you need. Marker is ultimately a DependencyObject which works with VisualTreeHelper.
Let me know if you need more information.
Thanks you,
In my implementation I override DataPoint and added my own custom member data. I guess what I really needed was away to tie a Button control instance back to the my CustomDataPoint instance so that when I click a button I can easily determine x, y, other custom data tied into the marker/data point instance, etc.
When I create a New Marker on the DataPoint, and set Marker.UseDataTemplate = true; I wanted to be abled to call FindName() to get my custom control instance and tie the control instance back to the underlying custom data point instance. But from here I can't call FindName(), and at this point I don't think the Button Control is created yet anyways.
So the only other options is to search the tree in the button click event using sender. But in searching the tree all I can get to is my control which has no DataPoint instance data, or something called MarkerTemplate which has ONLY the following members
FillStrokeStrokeThicknessToolTip
Well it was ugly but ToolTip ends up being filled with the DataPoint's tooltip, so I use it to hold an indexer that I can use to lookup the DataPointinstance in an array.
Is there a better way to do what I need to? I guess what I really need is a tag property or something?
WIthout resorting to keeping global variables somewhere which are assigned when parts of the chart are loaded, I would say you have found one of the easier ways to solve this issue.
Thanks,