Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed one WPF form into another?

Tags:

wpf

embedding

I would like to have master WPF form with tab control where each tab contains one independent WPF form. Those forms do not depend on each other, so I thought it will be easier to develop each of them separately and then just embed them into master form.

Number of forms is known, so there is no need for dynamic plugin system.

like image 452
zendar Avatar asked Dec 18 '22 09:12

zendar


1 Answers

When you use a Frame or NavigationWindow you can have it load different xaml Pages and even html. You can also make it act like a browser with forward and backward navigation. See http://msdn.microsoft.com/en-us/library/ms750478.aspx

You could put a Frame on each tab and have it load a certain Page.

<Window x:Class="PluginApplication.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <DockPanel>
        <Frame Name="frame" NavigationUIVisibility="Visible" Source="SomePage.xaml" />
    </DockPanel>
</Window>

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    WindowTitle="Page Title"
    WindowWidth="500"
    WindowHeight="200">
  Hello world
</Page>
like image 100
Lars Truijens Avatar answered Dec 30 '22 22:12

Lars Truijens