Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,822 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi
what is the appropriate way to show pages vertically (something like MS word...) and adding pages at run time?
thanks in advance.
Welcome to our Microsoft Q&A platform!
I made an example,you can use button to add random color pages。
xaml:
<ScrollViewer x:Name="scrolls" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
<ScrollViewer.Content>
<StackPanel Name="mystackpanel" ScrollViewer.VerticalScrollBarVisibility="Auto">
<Button Content="btn1" Click="Button_Click"/>
</StackPanel>
</ScrollViewer.Content>
</ScrollViewer>
C#
public partial class MainWindow : Window
{
int i = 1;
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Frame frame = new Frame();
Page page = new Page();
Random random = new Random();
page.Background = new SolidColorBrush(Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)));
page.Height = 200;
page.Name = "Page" + i.ToString();
frame.Content = page;
mystackpanel.Children.Add(frame);
i += 1;
}
}
Thanks.