We are having wpf user control (UserControl.xaml) in one dll (Child.dll).
We added the reference of "Child.dll" in to another application (ParentApplication)
In parent application we have one stackpanel in which we have to add the user control dynamically using the user control constructor.
ParentApplication contains :
MainWindow.xaml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fa="http://schemas.fontawesome.io/icons/" x:Class="ParentApplication.MainWindow"
xmlns:Mvis="clr-namespace:Mvis;assembly=Mvis"
Title="MainWindow" Height="1000" Width="1000" WindowStartupLocation="CenterScreen" WindowState="Maximized">
<Grid>
<TabControl>
<TabItem Cursor="Hand">
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="ChildApplication"/>
</StackPanel>
</TabItem.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True" Grid.Row="0" >
<StackPanel x:Name="userControlPlaceHolder" Background="Blue"/>
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>
So we doing it like this on MainWindow.xaml.cs :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
UserControl userControl = new UserControl();
this.userControlPlaceHolder.Children.Add(userControl);
}
}
Issue 1: User control is displayed only in half height of the screen.
**Note: We did not set any height to UserControl.xaml and we can not set the height control height like userControl.Height=200; **
Issue 2: We have used scroll viewer in MainWindow.xaml, but when we resize the application window, vertical scroll bar is not displayed.