Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

wpf graph error with cursor on different plots

Hi all

I  wrote a UserControl to analyze acquired data. I have a WPF Graph control in the UserControl and I have a problem with a cursor.

I have a test project with a window on which I put the UserControl and, when the window is initialized, I add programmatically two plots to the WPF Graph.

I have a cursor defined in the WPF Graph and if I move the cursor along a plot everything is ok, but if I try to move the cursor from a plot to the other I get the following error: InvalidOperationException - Cannot draw outside a draw cycle.

I tried the same thing on a single project, directly on a window (without UserControl) and I didn't get the error.

 

I'd like also to have explanations on plots... I noticed that when I add, for example, a collection of Point to the graph.Data collection (or to a collection binded to graph.DataSource) a new plot is drawn, but no new Plot is added to the graph.Plots collection (why this choice?).

I do both these operations when I have to add a new Plot and the question is: there is an order to follow? Is it necessary to create and add a new Plot before adding the Point[] to graph.Data or the order is not important?    

 

Thank you

 

0 Kudos
Message 1 of 5
(6,352 Views)

Sorry for the delay in getting back to you. I wanted to let you know we have been able to reproduce the error, but have not yet found a workaround (beyond the one you already identified of avoiding the user control).

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

I noticed that the error is given by the legend, in particular by the cursor item within the legend. If I define an ItemTemplate (different from the default one) I don't get any error.

I used this simple template, just to try...

<UserControl.Resources>
        <DataTemplate DataType="{x:Type ni:Cursor}">
            <ToolBarPanel Orientation="Horizontal">
                <ToggleButton Content="{Binding Name}"></ToggleButton>
                <ToggleButton Content="SnapToData" IsChecked="{Binding SnapToData, Mode=TwoWay}"></ToggleButton>
            </ToolBarPanel>
        </DataTemplate>       
    </UserControl.Resources>

 Hope it can help to find out the problem

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

I wanted to let you know we have isolated the root cause of this issue. It appears that graph size changes that occur during cursor drags cause multiple overlapping invalidation events: when the cursor moves to a different plot, the legend for the cursor updates to show the new plot name, causing the size of the legend (and the neighboring graph) to change, leading to invalid redraws.


If you want to use the existing legend item template, another workaround would be to give the legend or grid column a non-Auto size. The custom legend data template is also a valid approach.

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

Just wanted to let you know this issue (#375229) was fixed in the Measurement Studio 2013 release.

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