11-30-2017 08:00 PM - edited 11-30-2017 08:01 PM
Hello friends,
I have been working on how to use cursors with a WPF graph in an MVVM application but I am having trouble accomplishing a few things. I have created a cursor on my graph with the following statement...
<ni:Cursor SnapToData="False" InteractionMode="Mouse" AllowablePlots="Single" Plot="{Binding ElementName = channelPlot}" HorizontalCrosshairLength="0" TargetSize="0,0"/>
I set the HorizontalCrosshairLength to 0 because I am only interested in the vertical crosshair. I set the TargetSize to 0,0 because I do not need anything to display at the intersection of the crosshairs.
With that being said I have the following questions...
Thanks!
Solved! Go to Solution.
12-01-2017 09:56 AM
1) You can use the ValueVisibility property to hide the display of the value.
2) By default, a Cursor takes a position in the center of the plot area at the time it is loaded into a graph. To change this position, you will need to call one of the Set*Position methods, such as SetRelativePosition or SetDataPosition.
3) Since you are hiding the target, you can use the CrosshairBrush property to change the color of your cursor.
12-01-2017 11:01 AM
phasen,
Thanks for your help!
12-01-2017 11:05 AM
For the Set*Position methods, you could also optionally create an attached property to do a one-time set using XAML, if that makes more sense for your scenario.
12-01-2017 11:26 AM
It sounds like that may make more sense for my scenario, I am unaware of how to implement an attached property though so I will do some research.
12-01-2017 12:39 PM
From a quick search, this article might be a helpful reference: Introduction to Attached Behaviors in WPF.
12-01-2017 04:31 PM
Thanks for the reference, I realized that I am going to have to be able to set the position of the cursors repeatedly (not just one time) so I am just going to use the code behind approach.