Link to home
Start Free TrialLog in
Avatar of dpbouchard
dpbouchardFlag for United States of America

asked on

wpf canvas confusion

<Canvas Margin="2" Name="cvsText" Grid.Column="1" Grid.Row="1" ClipToBounds="True">
   <Canvas Name="cvsChart" ClipToBounds="True"/>
   <Canvas Name="cvsInputs" ClipToBounds="True"/>
</Canvas>

I have the above xaml for a 2d drawing app.  On the cvsText object, I'm drawing the x and y grid lines and all works fine.  On the cvsChart object, I'm drawing the polygon objects of my app.  On the cvsInputs I need to draw the graphic objects that change based upon the user inputs.  What I am trying to do is to use the cvsInputs canvas to draw things that I need to clear every time the user input changes,  However, every time I write on that layer, using the below vb code, nothing happens.  I've tried everything i could think of, changing the zindex of the canvas cvsInputs, the z index of the polygon, all to no avail. Any ideas as to why nothing I draw on the cvsInputs canvas shows up???  When I change only the target canvas to cvsChart, everything shows up just fine so I know the data is being read from the excel sheet just fine.

    Private Sub DrawMacAdamsElipse()

        Dim clsBBLCTR As classBBLCtr
        Dim pl As Polyline
        Dim intRow As Integer
        Dim intLastRow As Integer
        Dim dblX As Double
        Dim dblY As Double

        Canvas.SetZIndex(cvsInputs, 1)
        cvsInputs.Children.Clear()

        If CInt(_ws_ColorCalc.Range(_rngCCTIndex.Address).Value) > 1 Then

            clsBBLCTR = _dictBBLCTR(_clsResults.TargetCCT.ToString)
            If clsBBLCTR IsNot Nothing Then

                'todo: add point code

            End If

            If CInt(_ws_ColorCalc.Range(_rngNumMAEsteps.Address).Value) > 1 Then

                pl = New Polyline
                pl.Stroke = Brushes.Black
                pl.StrokeThickness = 2
                'pl.FillRule = FillRule.EvenOdd

                intRow = 1
                intLastRow = _rngMacAdamsEllipse.Rows.Count

                Do

                    If intRow > intLastRow Then Exit Do

                    dblX = CDbl(GetCellValue(_ws_CIE1976_MAE.Range(_rngMacAdamsEllipse.Address).Cells(intRow, 1)))
                    dblY = CDbl(GetCellValue(_ws_CIE1976_MAE.Range(_rngMacAdamsEllipse.Address).Cells(intRow, 2)))
                    pl.Points.Add(NormalizePoint(New Point(dblX, dblY)))

                    intRow += 1

                Loop

                cvsInputs.Children.Add(pl)

            End If

        End If

    End Sub
ASKER CERTIFIED SOLUTION
Avatar of mikebirt
mikebirt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial