You could implement it in Xaml. When the height of the StackPanel is greater than the height of the ScrollViewer, the ScrollBar works. If I misunderstood, please let me know.
ModalWindow.xaml:
<Window x:Class="SaveFileFromMultipleTabItems.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SaveFileFromMultipleTabItems" WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
Title="Window1" Height="360" Width="400">
<ScrollViewer x:Name="myScrollViewer" Height="360">
<StackPanel x:Name="Stacker" Height="460">
<Button Click="Button_Click" Content="click"/>
<Button Click="Button_Click" Content="click"/>
<RichTextBox Width="200" Height="100" FontSize="40">
<FlowDocument>
<Paragraph >
<Run >Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1</Run>
</Paragraph>
<Paragraph >
<Run >Paragraph 2,Paragraph 2,Paragraph 2,Paragraph 2,Paragraph 2</Run>
</Paragraph>
</FlowDocument>
</RichTextBox>
<RichTextBox Width="200" Height="100" FontSize="40">
<FlowDocument>
<Paragraph >
<Run >Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1,Paragraph 1</Run>
</Paragraph>
<Paragraph >
<Run >Paragraph 2,Paragraph 2,Paragraph 2,Paragraph 2,Paragraph 2</Run>
</Paragraph>
</FlowDocument>
</RichTextBox>
<TextBox Width="200" Height="50" Text="hello" TextWrapping="Wrap" FontSize="40"/>
<TextBox Width="200" Height="50" Text="hello" TextWrapping="Wrap" FontSize="40"/>
</StackPanel>
</ScrollViewer>
</Window>
Modal.xmal.cs:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("hello");
}
}
MainWindow.xaml:
<StackPanel >
<Button Content="open modal window" Height="40" Click="Button_Click"/>
<Button Content="click" Height="40" Click="Button_Click_1"/>
</StackPanel>
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Window1 window = new Window1();
window.ShowDialog();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBox.Show("hello");
}
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi,@TmeedEl Shalom . Did my answer solve your problem? If so, you could accept it as the answer. It's helpful for community members with similar questions. I'd be happy to help if there are still questions.