ScrollBars are not visible after changing positions of controls inside a Canvas

Posted by akjoshi on Stack Overflow See other posts from Stack Overflow or by akjoshi
Published on 2010-06-17T11:56:52Z Indexed on 2010/06/17 13:03 UTC
Read the original article Hit count: 418

Filed under:
|
|

Hi,

I created a custom canvas control inheriting from WPF Canvas. I am using it like this in main window -

<ScrollViewer
    HorizontalScrollBarVisibility="Auto"
    VerticalScrollBarVisibility="Auto">
    <RTD:RTDesignerCanvas
        Margin="5"
        Background="White"
        x:Name="canvas1"
        Focusable="True"
        AllowDrop="True">
    </RTD:RTDesignerCanvas>
</ScrollViewer>

Everyhting works fine but when I try to set the position of controls inside it like this

Canvas.SetTop(item, 200);

scrollbars are not visible and control is hiddedn down somewhere. Intrestingly, if I add another control to it scroll bars are visible and I can scroll downwards to see the previous control.

I tried to use

base.InvalidateVisual();
base.UpdateLayout();
base.InvalidateArrange();

after changing items Top or Left but nothing happens; Am I missing something or this happens due to some bug?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about canvas