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...
19 Replies - 1311 Views - Last Post: 29 December 2012 - 03:53 AM
Replies To: Automatic scrolling
#2
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.
#3
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...
#4
Re: Automatic scrolling
Posted 26 December 2012 - 10:32 AM
If its like the stackpanel I know, WPF and Silverlight:
Width = Auto
#5
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
#6
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.
#7
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
I must did something wrong, but I don't know what
#8
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.
#9
Re: Automatic scrolling
Posted 27 December 2012 - 02:41 AM
I tried it, but it was same...
#11
Re: Automatic scrolling
Posted 27 December 2012 - 08:26 AM
This is code(before any changes from replies of this forum)
XAML:
Adding new radio button:
Removing radio button:
I'm using radio buttons as tabs, flipview as tabcontrol, tag as indentifier(to connect flipview item and radio button) and i as index...
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="" 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="" 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="" Padding="4,2" FontFamily="Segoe UI Symbol" FontSize="10" BorderThickness="0,0,0,2"/>
<Button x:Name="b9" Content="" 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="" 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...
#12
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.
#13
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"
#14
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.
#15
Re: Automatic scrolling
Posted 27 December 2012 - 02:38 PM
Quote
Everything position-wise in WPF is set by margins and alignments
...should be
|
|

New Topic/Question
Reply




MultiQuote



|