Animation for SizeToContent resizing - wpf

In WPF window, I have specified SizeToContent="WidthAndHeight".
I have a number of panels stacked up, of which I change the visibility (to Visible or Collapsed) as required. My window resizes itself according to the panel that I have set visible. No issues here.
My problem is with the resizing, that the window resizes with a jerk to the final size.
I want to animate this such that the resizing is smooth. And i want to do this in my XAML file.
Is there any solution for this???
P.S. - I have not set any Width or Height property in the window and I want to restrict myself from doing that.

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.

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.

Changing RectangleGeometry.Rect on window resize in WPF

I have a RectangleGeometry for clipping a certain area of a window. However, when the window is resized I'd like the RectangleGeometry.Rect property to be adjusted such that the clipping position doesn't change as the window resizes. Is there an event I'd have to lookout for to dynamically change the property? Any help is appreciated
You should be able to handle the SizeChanged event on your Window, then adjust your clipping rectangle accordingly.

.NET Tab Contol. Not scroling when chield control have a min size and anchor right

I have a simple dialog with tab control whit property Dock = Fill. On the tab page I add another control and set its properties Anchor as 'Left, Top, Right' and min size as '600,300' for example. I set the property of tab page AutoScrolling to true.
But when I resize the dialog the horizontal scrolling of the tab page doesn't work when the dialog width is smaller than min width of the chield control.
Why horizontal scrolling doesn't work in this case? Is it bug or maybe feature?
Thanks a lot!
I can't even get the scrollbar to show up. Right/bottom anchors don't work well when auto-sizing layout. Set the AutoScrollMinSize property to an appropriate value, that also ensures you've got enough margin to the right of the button.
It's because of the Anchor. You anchored it on the left and right which means that it will have no minimum width, its width is determined by its container's size.
What is the effect you're trying to achive?

How to make WPF WebBrowser grow horizontally and vertically?

In WPF, we are using a WebBrowser control to view HTML content. When we place the control on our window, it grows horizontally with the window as it grows/shrinks. However, we have not found a way to make the control grow vertically with the window. We are looking for some sample code that will allow the WebBrowser WPF control to grow both vertically and horizontally with the window.
With WPF and wanting to grow with the window, the magical starting point is to set the Margin to 0 and avoid setting width and height. (You can have margin equal to another number, but start with zero and see how it looks first!)
Another option is to use a dock panel with last child fill set to true, where the web browser control is the last element (as you read down the page - it doesn't have to be the last element in the rendered UI.

Resources