Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

set graph properties in code behind

Solved!
Go to solution

I am trying to add graphs dynamically in the WPF code behind. This works fine, but I can't find a way to set the default interaction to zoom and the interactions to pan - is it possible to do this in code behind?

0 Kudos
Message 1 of 6
(6,016 Views)
Solution
Accepted by topic author BeckyHayter

Yes, you can set both the allowed Interactions and the DefaultInteraction on a graph to any valid GraphInteraction instance. For example:


    graph.DefaultInteraction = GraphInteraction.Zoom;
    graph.Interactions = new GraphInteractionCollection { GraphInteraction.Pan };

~ Paul H
0 Kudos
Message 2 of 6
(6,008 Views)

Another question regarding code behind and graphs. I am generating plots in my code behind by binding the graph datasource to an observable collection of points[], is there a way to set the label property of each plot when doing this? I would like to do this so i can make the legend display correctly.

0 Kudos
Message 3 of 6
(5,992 Views)

There is no way to bind the label of an automatically generated plot in the current version of Measurement Studio. To get a custom label in the legend, you will need to add a plot with that label to the Plots collection on the graph.

~ Paul H
0 Kudos
Message 4 of 6
(5,987 Views)

Ok thats no problem. Is there any way to set the width of a graph (or a legend) to "*" in the code behind?

0 Kudos
Message 5 of 6
(5,955 Views)

If you mean auto size, using Control Width="Auto" in XAML is equivalent to setting control.Width = double.NaN in code. "Auto" is the default value for width and height on all controls.


If you mean star size on a grid containing a graph, using ColumnDefinition Width="*" in XAML is equivalent to setting columnDefinition.Width = new GridLength(1.0, GridUnitType.Star) in code.

~ Paul H
0 Kudos
Message 6 of 6
(5,950 Views)