I have read that I can't have my dockpanel scroll so im looking for alternatives
I want to have a lot of slider controls(unknown number) left to right in a panel of some sort that can scroll so I can view all the sliders. I tried with dock panel but of course that didn't work. What can I do to make the dockpanel work or what do I replace dockpanel with(the replacement would need to support children)?
Thanks!
EDIT:
http://i.stack.imgur.com/J5a4u.png
here is the idea but it needs to scroll horizontally
David Brunelle Does work but its not quite what I want. Id like the scroll bar to be on the top of the control and not attached to the bottom of the window.
I'm not sure I understand, but you can use a panel within a ScrollViewer
Something like this :
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="2,2,2,2">
...
</StackPanel>
</ScrollViewer>
This will allow for vertical scrolling. You could do the same for horizontal scrolling. I do not know if this would work with a docking panel, but I know it does with a stack panel.
Hope that helps.
I would use a ListBox as it will handle the scrolling part for you, then you can set the ItemTemplate (if you want) and you can use data binding (using an ObservableCollection or a DataView
Related
I have an application that works with different tabs. At left side I have my menu and at the middle I have DockPanel. According to menu selection I am adding a windowbase window as child to my dock panel and with mouse ball scroll but it does not scroll. Normally when you are over scrollviewer area it automatically triggers scrolling but for dock panel its just moving when I am over scroll bar not on whole dock panel.
Thanks guys I was thinking that when I add scrollviewer into the DockPanel and clear children than the scrollvier also be removed. But it is not like that.At the beggining I was using it like following code
<ScrollViewer x:Name="innerScrool" VerticalScrollBarVisibility="Auto" VerticalAlignment="Top" MinHeight="350"><DockPanel Margin="0,10,0,0" VerticalAlignment="Top" x:Name="ControlPanelContent">
But I change the code take the scrollviewr inside and the problem solved.
I'm trying to create grid with listbox with Scrollbar.
It's done somehow like that:
<Grid>
<ListBox Name="xxx" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible">
....
</ListBox>
</Grid>
The problem is that if I use scrollbar, then the size of bar-button jumps back and forward within scrolling. If I remove ScrollViewer from properties and instead put ListBox in ScrollViewer tag, then everything is working perfect, except of terrible performance of rerendering UI (resize, move window, resource consuming). According to google it does "disable virtualization". This sounds crazy that there's no simple solution to get properly working scrollbar and usable UI without issues.
Is there compromise for both of these things? Virtualization + properly working scrollviewer with fixed size of scrollbar button.
I have a simple scrollviewer setup in my wpf application. Everything works fine, Now I want my scrollviewer's content should use the space of my the scollbar as well, As my scrollbar is transparent it could easily display the content.
Just like the scrollbars in facebook. Attached is the image of the output. Green Section is the content and red section is scollviewer's area.
I am using WrapPanel in my scrollviewer, this is the code snippet
<ScrollViewer x:Name="ScrollViewer1"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Hidden">
<WrapPanel x:Name="WrapPanel1" SizeChanged="WrapPanel1_SizeChanged" />
</ScrollViewer>
You have to edit the ScrollViewer's ControlTemplate which should look like the one in this page : http://msdn.microsoft.com/en-us/library/aa970847(v=vs.110).aspx
In the ScrollViewer Control Template Example, you can see that the ScrollContentPresenter is inside a Border which is inside the first row of a 2-rows Grid.
Setting the RowSpan to 2 for this Border would achieve the effect you want.
I want to put lots of controls inside a StackPanel and user can scroll up and down. I have a simple StackPanel inside a grid.
<Grid>
<StackPanel>
</StackPanel>
</Grid>
If I'm not wrong, I've seen that StackPanel scrolls, but now it is not working. Does it support scrolling or it is not supported at all? ( I prefer not to put it inside a ScrollViewer). thanks
Nothing really scrolls unless it has a ScrollViewer inside. When you do it like you're doing it now, you'll see only the items that fit on the screen, and others will be 'out of screen borders'.
So I'm afraid you'll have to add a ScrollViewer. It's actually a good thing that StackPanel doesn't scroll by default.
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