I have made some custom attached properties that enable me to create a "pop out" effect on any control.
It animates the width and/or height when a boolean DependencyProperty is toggled.
Is there a good way to set all ScrollViewer's scrollbar visibility inside the control to hidden during this effect? You can see some ugly scrollbars appear during the animation.
I would rather not have to traverse the visual tree at the start of the animation, and then do it again when the animation completes.
EDIT: Although an alternate solution would be nice, at this point I'd rather bind to a readonly attached property named IsAnimating to handle setting the scroll visibility.
Is there a global way to to this?
Instead of animating the width of the control itself, try fixing its width at the start of the animation and reparenting it into a grid, and animate the grid's width instead. The original visual wouldn't change size in its own little world, and no scroll bars would appear or change.
Related
I have some textblocks included in a scroll viewer. I don't want to use the horizontal scrollbar so I came up with this idea but I don't know how to do this.
If you're referring to Screen size as the immediate window or page or just view of whatever in XAML you can easily bind the TextBlock.Width to the ActualWidth of that hosting element.
If you're talking about the actual monitor screen size then you just need to create a ViewModel with that property exposed and then bind that the same way.
If you need code let me know.
TextBlock has a property called TextWrapping. This will allow you the data in your TextBlock Not to overflow but increase the Height of TextBlock Itself. Also make sure to set VerticalAlignment to Stretch.
In WinRT, the ScrollViewer is a convenient control that supports Zoom/Pan features for its content in default. But I got stuck on controlling the Zoom/Pan features of the ScrollViewer's content in code-behind(c-sharp file). If I know how ScrollViewer works, the problem should be solved as expected.
Note: I've tried to write the event-handling method to listen to ScrollViewer's ManipulationXXX event, but it hadn't been run into. Only I can listen to ScrollViewer's ViewChanged event.
I can get ScrollViewer object's ZoomFactor property which tells you the current zoom value. If you want to change the zoom value of the content, just use ZoomToFactor(float factor).
I'm trying to recreate the layout of the Weather app in XAML / C#. I have a ListView full of ListViewItems. It is one of several objects within a ScrollViewer. The end result should be that the user can scroll horizontally through the Objects, but stop on the ListView and scroll vertically.
For the effect to work, the ScrollViewer must match the height of the page, and the ListView must match the height of the ScrollViewer, without stretching it.
I can't figure out how to do this without using code-behind to find the Window.Current.Bounds and apply the height to the ScrollViewer, this seems like a dirty hack. Is there a way to do this purely in XAML?
The ListView has its own scrollbar stuff, without needing a ScrollViewer. Otherwise to make things stretch it should be pretty easy - how are you putting things in the ScrollViewer? Through a Grid? A StackPanel?
This may be what you are looking for, but you may find it useful to achieve a 'weather app' look and feel:
http://dotnetbyexample.blogspot.co.uk/2012/08/a-winrt-behavior-to-turn-flipview-into.html
In a WPF application, I'd like to create a textbox dynamically which will show in front of the application and be able to freely set its location by pixel. (The textbox is going to follow the mouse cursor).
This was easily done in Winforms on the fly but WPF makes things.. a little bit weird when it comes to setting a control's location by pixel since I have to add the control as a child of a container. I'm aware this is certainly doable on Canvas, but what I actually have is a dockpanel with a richtextbox to the left and a datagrid to the right.
So what are my options here? Do I have to use canvas? Can I get away with using dockpanel (or grid) to implement what I want here?
You can use a Canvas or a Grid. If you use a Canvas, set the Canvas.Left property and the Canvas.Top property. If you use a Grid, you'll need to set a size for your TextBox, set the HorizontalAlignment to Left, and VerticalAlignment to Top. To change the location of the TextBox, assign it values for MarginLeft and MarginTop.
I'm currently writing a marquee control for WPF. The control consists of an ItemsControl, with TextBlock as the DataTemplate element of choice. The ItemsControl is the target of a Double Animation, which manipulates the Canvas.Left property.
What I would like to do is create a "circular mode", which will allow the marquee to dynamically add an item to its' tail whenever the last item has scrolled into view. That way, the marquee will never appear empty.
How can I detect when a TextBlock has "scrolled" into view (effectively become visible) as a result of the animation?
It might work that you check whether the ItemControl's ActualWidth property is greater than the current Canvas.Left value of your TextBlock.
To get the change event, have a look at this SO: How do I handle Canvas.Top change event in WPF?
Maybe it is useful to keep a references to the last control that was added to the tail of your marquee, so that you can remove the event handler once the control is scrolled into view and attach the event handler to the TextBlock that is then added to the tail.
It would be nice to be able to draw something for a better understanding. If anything's unclear (technically or conceptually) ask, ask, ask... :)