Automatic scrolling

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 6035 Views - Last Post: 29 December 2012 - 03:53 AM Rate Topic: -----

#1 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Automatic scrolling

Posted 26 December 2012 - 09:14 AM

I'm programing application in Visual Basic 2012 For Windows 8, there is a Stack panel on the top of the screen, where radio buttons are dynamically added or removed...I need to set panel will be scrollable when radiobuttons reach screen width.... Thank's for help...
Is This A Good Question/Topic? 0
  • +

Replies To: Automatic scrolling

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

Re: Automatic scrolling

Posted 26 December 2012 - 10:13 AM

Is it a regular panel? If so just set the Autoscroll property of the control to true, it should set up scrolling for you.
Was This Post Helpful? 0
  • +
  • -

#3 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 26 December 2012 - 10:27 AM

It's a normal stack panel(XAML control), and I can't find autoscroll property at it's properties, I only found a Hscrollviewer and Wscrollviewer visiblity, but when I set it to "visible" or "hidden", it don't do anything...
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: Automatic scrolling

Posted 26 December 2012 - 10:32 AM

If its like the stackpanel I know, WPF and Silverlight:

Width = Auto

Was This Post Helpful? 0
  • +
  • -

#5 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 26 December 2012 - 10:39 AM

I tried it, but it's same as was before it, but thank's for help to all :)
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: Automatic scrolling

Posted 26 December 2012 - 10:57 AM

Sorry, the width auto keeps it the same width as the parent container. You will to resize it with each RB added/removed.
Was This Post Helpful? 0
  • +
  • -

#7 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 26 December 2012 - 11:43 AM

Hmmm, container of that panel is grid(that is main container of all) but when i set width to auto, enable scrolling and then set width of a grid to bigger size than screen's width, it don't do anything.
I must did something wrong, but I don't know what :(
Was This Post Helpful? 0
  • +
  • -

#8 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: Automatic scrolling

Posted 26 December 2012 - 12:06 PM

Try a ScrollViewer with it's content being a StackPanel and resize the StackPanel and the ScrollViewer will handle the scrolling.
Was This Post Helpful? 0
  • +
  • -

#9 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 27 December 2012 - 02:41 AM

I tried it, but it was same...
Was This Post Helpful? 0
  • +
  • -

#10 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

Re: Automatic scrolling

Posted 27 December 2012 - 07:31 AM

Post your XML and code
Was This Post Helpful? 0
  • +
  • -

#11 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 27 December 2012 - 08:26 AM

This is code(before any changes from replies of this forum)
XAML:
<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid x:Name="grid" Background="SteelBlue">
        <Grid.RowDefinitions>
            <RowDefinition Height="191*"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel x:Name="stp2" HorizontalAlignment="Left" Height="39" VerticalAlignment="Top" Width="733" Orientation="Horizontal" Background="SteelBlue">
            <Image x:Name="b4" Width="45" Source="Assets/SmallLogo.png"/>
            <Button x:Name="b5" Content="+" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" RenderTransformOrigin="-1.096,0.528" Width="45" BorderThickness="0,0,0,2"/>
            <Button x:Name="b6" Content="-" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" RenderTransformOrigin="-1.096,0.528" Width="45" BorderThickness="0,0,0,2"/>
            <Image x:Name="im1" Width="45"/>
            <TextBox x:Name="TextBox1" TextWrapping="Wrap" Width="326" FontSize="20" BorderThickness="0,0,0,2" Height="33" Padding="1,1,0,1" Background="SteelBlue" Foreground="White" MaxHeight="32"/>
            <Button x:Name="b7" Content="&#xE19F;" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" Width="45" FontSize="12" Padding="4,2" FontFamily="Segoe UI Symbol" BorderThickness="0,0,0,2"/>
            <Button x:Name="b8" Content="&#xE1CF;" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" Width="45" FontFamily="Segoe UI Symbol" FontSize="10" Padding="4,2" BorderThickness="0,0,0,2"/>
            <Button x:Name="b3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click_2" Width="45" Content="&#xE0D5;" Padding="4,2" FontFamily="Segoe UI Symbol" FontSize="10" BorderThickness="0,0,0,2"/>
            <Button x:Name="b9" Content="&#xE1A3;" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" Width="45" FontFamily="Segoe UI Symbol" Padding="4,2" FontSize="10" BorderThickness="0,0,0,2"/>
            <Button x:Name="b1" Content="&#xE0E7;" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Click="Button_Click_2" Height="39" Width="45" FontFamily="Segoe UI Symbol" Padding="4,2" FontSize="10" BorderThickness="0,0,0,2"/>
        </StackPanel>
        <FlipView x:Name="fp1" HorizontalAlignment="Left" Margin="0,39,0,0" VerticalAlignment="Top" Width="1366" Height="729" Grid.RowSpan="2">
        </FlipView>
        <StackPanel x:Name="stp1" HorizontalAlignment="Left" Height="39" VerticalAlignment="Top" Orientation="Horizontal" Margin="733,0,0,0" Background="SteelBlue" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" Width="633"/>
    </Grid>
</Page>


Adding new radio button:
Dim rb As New RadioButton
        rb.Tag = cc
        rb.Content = i
        rb.Margin = New Thickness(6, 0, 6, 0)
        AddHandler rb.Click, AddressOf rb_click
        stp1.Children.Add(rb)


Removing radio button:
 For Each rbu As RadioButton In stp1.Children
                If rbu.Tag = z Then
                    stp1.Children.Remove(rbu)
                End If
            Next


I'm using radio buttons as tabs, flipview as tabcontrol, tag as indentifier(to connect flipview item and radio button) and i as index...
Was This Post Helpful? 0
  • +
  • -

#12 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: Automatic scrolling

Posted 27 December 2012 - 09:33 AM

<ScrollViewer>
  <ScrollViewer.Content>
     'Stackpanel goes here
  </ScrollViewer.Content>
</ScrollViewer>


Then you need to set the stackpanel width to the width of all radiobuttons and margins - could be a simple function that you call when you add or subtract RBs.
Was This Post Helpful? 0
  • +
  • -

#13 xxxpetko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-December 12

Re: Automatic scrolling

Posted 27 December 2012 - 01:04 PM

I tried it and I tried add some parameters to scrollviewer, but in every way it result to "stack panel can't be seen" or "buttons on left,top positions on screen can't be clicked"
Was This Post Helpful? 0
  • +
  • -

#14 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: Automatic scrolling

Posted 27 December 2012 - 02:10 PM

I don't understand can't be seen(check margins) or can't be clicked(is there an event handler)??? Everything position-wise in WPF is set by margins and alignments - please check these.
Was This Post Helpful? 0
  • +
  • -

#15 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 769
  • Joined: 19-October 11

Re: Automatic scrolling

Posted 27 December 2012 - 02:38 PM

Quote

Everything position-wise in WPF is set by margins and alignments

...should be
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2