Scroll to WPF elements outside boundary - wpf

I'm editing a WPF Window object in Visual Studio and have a canvas element that stretches outside the boundary of the Window. Visual Studio only gives a zoom in/out feature, but I can't scroll left or right, even though my canvas inside the Window stretches way off the right of the screen. How can I scroll out all that way?
Thanks,
Dave

Your big canvas must be contained in another container with a constrained size. Try to set SizeToContent="WidthAndHeight" on the window.

Related

WPF control is on top of the window border, how do I stop that?

I have a WPF window and an Image in a grid in the window. I am animating the Image so it moves from out of view (beyond widow location) into the window.
The animation is nice and smooth and everything works but I notice the image is over top of the window border while it is moving. The image at the end of this question is what it looks like.
Why would the image be over top of the window border, and how do I get it to be "under" the border?
Thanks in advance!
Well after a lot of trial and error it seems the problem was the fact I was moving the image in a grid that had no defined width, so the width would expand over the border when moving the image thus extending the "client" area of the window and showing over the window area.
Once I defined a specific width of the grid, everything worked.

How to specify z-index for a panel

Hi I'm new to WPF and I want to place a Panel upon a StackPanel and show and hide it in my window without using Canvas and changing positions and size of other controls or the window.
Something like the fallowing image which the solution explorer is opened on another Panel, and as we see the user even can change the position of the Panel.
If you have a Grid as the Root Layout and a StackPanel on that, you can still use Canvas.
Canvas.SetZIndex(<YourPanelYouWantInFront>, <LargeValue (100)>);

Silverlight 4/WPF - Nested ScrollViewer panel that scales with available screen size

In the Windows Forms world you can take a panel and set it's dock property to fill and so on with nested panels, when the user resizes the window the panels and nested panels automatically resize too. I want to achive something similar with Silverlight, here is my current structure.
Main
ScrollViewer // for body
UserControl
Grid
control
Scrollviewer // this is where my problem is
Control
The problem is I can set a size for the nested scroll viewer that looks good for 1024 resolution, but I also want to account for users that have larger resolution. If I leave it auto the content just stretches below the visible bottom line and defers to the top level ScrollViewer.
If I could achieve something analogous to how Windows Forms handles this with docking I think my problem would be solved. I must have a ScrollViewer for the nested panel and I want it to fill all visible space left. How Can I achieve this with SL4 or WPF?
[Edit]
Here is an illustration of what i'm after.
The top-level ScrollViewer allows its content to be as large as it needs to be, and adds scrollbars if that means they don't fit in the window. Its children no longer know or care how tall the window is; they just know that they've got as much space as they want.
So what is it that you want from your nested ScrollViewer? It's got all the space it needs, so it will grow to show all of its content -- there's nothing to restrict it to the height of the window. In fact, you added a top-level ScrollViewer, which specifically told it "don't restrict it to the height of the window".
If you want your inner ScrollViewer to be restricted to the window height, then take out the top-level ScrollViewer.

How to move WPF window above top of screen?

I have a window with the following:
Background="{x:Null}" AllowsTransparency="True" WindowStyle="None"
Dragging the window by hand beyond the left, right and bottom limits of the screen results in a predictably cropped window. However this behaviour is not the same for dragging it above the top limit. Instead of cropping, it pushes it back down as if there's an automatic If Window.Top < 0 Then Window.Top = 0.
This is probably in place so that users don't lose a Windows titlebar (which is the standard way to drag windows around, and losing sight of that effectively makes it undraggable). I don't need that as my entire window is draggable via Me.DragMove().
So, how do I let a window be dragged above the top limit of the screen?
(This is unrelated to Aero Snap which only occurs if the mouse touches the borders. I'm trying to move the window beyond visible bounds)
The DragMove function do not allow you to drag a window above the screen. You need to manually move the window, for example:
How do I move a wpf window into a negitive top value?

WinForm designer and right snapline for controls in container when resizing it

Using Visual Studio 2008 WinForm designer, I have a container (form, panel, groupbox, whatever) and some controls in it.
The container is set to not automatically resize or dock in any way. When placing a control in the container I can use the snaplines to help in positioning the control.
However, the snaplines does not appear when I resize the container to the edge of the contained controls...
Is there a simple way to have the designer show me the snaplines of the contained controls when resizing the container?
The designer will only show the snap lines when moving a child control within a container. You can demonstrate it by moving a GroupBox around a Form and see that it shows snap lines when the GroupBox gets close to the edge of the Form, but if you were to resize the Form you won't see the snap lines appear.
If you're just looking to get all of the controls to line up in a uniform fashion, I'd suggest switching to SnapToGrid mode and using the grid lines to align your controls. You can set the SnapToGrid mode by going to Tools->Options->Windows Forms Designer->LayoutMode. Open your designer and you should see the grid appear, after that you can line your controls up with the grid.
After setting the layout of the form, you can also set anchoring property to all child controls appropriately, to right and bottom (or top and left), depending on the resizing you are making. Anchor property will hold child controls to same distance from the edges of the container (parent control).
In the WinForms designer, there is no support for snaplines when resizing the container control. The best way to work around this issue is to first size the container to the size you would like to use and then add controls. Optionally, you can change the Margin property of the container so that when moving controls inside the container, they will snap to the margin of the container, keeping it uniform.
Try:
container.AutoSize = true
container.AutoSizeMode = GrowAndShrink
container.Padding.All = 5

Resources