开发者

WPF questions (SizeChanged event, scrollviewer+canvas)

I am trying to put a ScrollViewer wrapped around a Canvas (a chart of some signals), but I can't seem to get it to work.

First of all, I have a user control that is a makes 2d line graphs (from a book that I'm following), and I am trying to modify it to customize it for my own uses. The relevant parts are:

My app (Window1.xaml)

    <Grid Grid.Column="1" Grid.Row="2">

        <local:LineChartControlLib x:Name="originalChart" Xmin="0" Xmax="51.2" Ymin="-3" Ymax="3" Background="White" Title="" GridlinePattern="DashDot" />

    </Grid>

The UserControl:

    <Grid Margin="0" x:Name ="chartGrid" Grid.Column="1" Grid.开发者_如何学PythonRow="1" ClipToBounds="True" Background="Transparent" SizeChanged="chartGrid_SizeChanged" />
    <Canvas Margin="2" Name="textCanvas" ClipToBounds="True" Grid.Column="1" Grid.Row="1">
        <Canvas Name="chartCanvas" ClipToBounds="False">
            <Canvas Name="legendCanvas" Background="Transparent" />
        </Canvas>
    </Canvas>

If I put a ScrollViewer around any of the grids of canvas in my app, the canvas doesn't show and the execution time is terribly slow. If I put a ScrollViewer around the grid or the Canvas in the user control, the "chartGrid_SizeChanged" event gets fired repeatedly (infinitely). Can anyone enlighten me on what I am not understanding? Thanks a lot.


The Canvas panel doesn't work well with scrollviewers. See this post for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜