Hey folks, I'm hoping I have a fairly simple problem that can be fixed easily as it seems like I'm just missing something basic from the WPF world. I have a scrollviewer wrapping a stackpanel which contains several images, these images have animations to increasing in size when the mouse passes over them. All works fine without the scrollviewer, now I've added the scrollviewer, the animation works but only inside the scrollviewer; the increasing size isn't being allowed to overlap the scrollviewer.
Is there a way to fix this?
Thanks,
Becky
It's the way ScrollViewer works. Basically it always clips to bounds even if you set ClipToBounds="False" on it.
To make it work and continue using ScrollViewer you'll have to animate images on top of it, not inside.
Related
I'm trying to create a gallery-style layout with a ScrollViewer and a WrapPanel in WPF, but the WrapPanel is extending beyond the boundaries of the ScrollViewer. I've tried setting the HorizontalAlignment and VerticalAlignment properties of the WrapPanel to "Left" and "Top" respectively, but it still doesn't stay within the boundaries of the ScrollViewer.
I've also tried setting the height of the WrapPanel to specific values and set the MaxHeight properties of the WrapPanel to limit the size, but it still doesn't stay within the boundaries of the ScrollViewer, and is no longer scrollable. I've also tried wrapping the WrapPanel inside a Grid and set the height of the Grid to the size I want and set the ClipToBounds property of the Grid as "True", but it still doesn't work.
I'm not sure what else I can do to keep the WrapPanel within the boundaries of the ScrollViewer. Can anyone help me figure out how to contain the WrapPanel within the ScrollViewer?
This is my xaml code:
<ScrollViewer Grid.Row="0">
<WrapPanel x:Name="Preview_WrapPanel"></WrapPanel>
</ScrollViewer>
and this is my result in my app, in the beginning, the distance from top is correct but the bottom not. I scrolled a little up to show that the height is not respected in the top region as well:
the width is respected, but i think only because this is the application width.
The thick red border is the area, which the scrollviewer occupies. The wrappanel should be contained inside, kind of like a window, where you can only see whats behind the window and not the trees behind the wall.
the wrappanel gets filled with WebView2 Media, each image around 200x200px:
WebView2 media = new WebView2();
media.Source = new Uri(nftFile.FullName);
media.Width = 200;
media.Height = 200;
this.Preview_WrapPanel.Children.Add(media);
I use Webview2 because the content could pretty much be anything, image, video, pdf, whatever. Also it supports webp
For now though, im only adding images.
There was a known bug with webview2 and it seems it has not been fixed.
Basically, renders on top so cannot be clipped.
https://github.com/MicrosoftEdge/WebView2Feedback/issues/2579
https://github.com/MicrosoftEdge/WebView2Feedback/issues/286
You need a different plan.
Maybe ensure it doesn't matter when they don't clip.
Maybe use images.
Or hope it gets fixed soon.
Andy was correct, this is a known issue. Microsoft knows about it since .net framework Times (>10 years) but refuses to fix the issue so far.
I solved the issue by Installing the Nuget Package CefSharp which uses the chromium engine as well.
What a pitty.
Within a WP7 app I am generating a Scrollviewer within the code. This Scrollviewer has a StackPanel as its content and within the Stackpanel I have a grid.
I have not assigned any specific heights to these controls.
As far as the look and the behaviour I am after, all is fine.
I now want to position the scrollviewer to a certain point - after I have generated it and its children.
It seems that the ScrollViewer.ScrollToVerticalOffset method is what I should be using.
But I cannot ascertain the height of the Scrollviewer... both Height and ActualHeight are returning 0. I want to use this height to determine which point I should be scrolling to.
And even when I hardcode a ScrollToVerticalOffet value then it still doesn't reposition itself.
Is there a way that I can get this to position as I want, and how can I determine the height values?
thanks
Got it working ok when I checked for values in the Page loaded event... and the ScrolltoOffset seemed to work fine there too.
I am working on a Silverlight application and my problem is like this: I have a StackPanel
and inside the stackpanel I have a ViewBox. Inside the viewbox I am adding images and rotating them 90 and/or -90 degrees.
When rotated, my images go out of the viewbox. How can I fix this?
Use something other than StackPanel, it doesn't resize.
There's a control in the Silverlight Toolkit that addresses this problem called the LayoutTransformer. It ensures that when you change the transform, the bounds of the control are within the LayoutTransformer bounds.
You can see this at work in the Silverlight Toolkit demo. Just scroll down the tree on the left to the Layout section.
I have a DataGrid in my silverlight application and I'm wondering how to get the same behavior for the vertical scrolling as the horizontal scrolling. When I resize the browser horizontally, The app will bunch up all the controls and the horizontal scrollbar will appear, however when I resize it vertially, the controls at the bottom of the app just move out of view. Does anyone know any tricks to handle something like this?
My problem is StackPanels. Don't use them, they are evil and don't resize.
I couldn't get the scrollbar to show up at all with the datagrid. Removing the datagrid from a stackpanel and using a grid instead also solved my problem.
Good call!
In my case the Height of the rowdefinition where I have the datagrid was set to "Auto" and it had a rowdefinition below with height set to *. I switched the values and it worked.
Yes stack panels causes some unknown errors in Silverlight, I Had also experienced problems with regards to stack panels like nesting data fields inside stack panels which are also inside data forms.
Been checking the web and this site, but couldn't come up with any descent results.
Is there a way to make a canvas in WPF show scrollbars on overflow ? Been trying the scrollviewer, but can't get it to work :(
Thanks in advance..
The problem you're running into is that Canvas, unlike many WPF panels and containers, does not size to contents. That means if you add an element which goes outside the canvas boundaries it will not update it's size. Hence embedding a Canvas in a ScrollViewer will do no good unless you manually update the size of the Canvas.
It sounds like what you want is a Canvas which supports size to contents. This blog entry has exactly that control.
http://themechanicalbride.blogspot.com/2008/11/auto-sizing-canvas-for-silverlight-and.html
I took a different approach and abandoned the Canvas for Grid. The Canvas is more performant but for my purposes at least I haven't noticed a difference. The grid can mimic the behavior of canvas by doing the following.
Create a single row,single column grid.
Set the HorizontalAlignment to Left
Set the VerticalAlignment to Top
Use Margin "x,y,0,0" to set the position.
Bam..works just like canvas and it works great in a Scrollviewer.