Dynamically adding usercontrol to MainWindow
Posted: 03 Apr 2014, 01:04
Hello,
I want to dynamically add usercontrol (defined in seperate xaml) to MainWindow.
Something like following:
xaml1.xaml is as following:
Is there any way to achieve this ?
Thanks.
I want to dynamically add usercontrol (defined in seperate xaml) to MainWindow.
Something like following:
Code: Select all
Noesis_LoadXAML(&mUIRoot, &mUIRenderer, "Gui/DC2/MainWindow.xaml");
Noesis_LoadXAML(&mPlugin1Root, &mPluginUIRenderer, "Gui/DC2/xaml1.xaml");
main_root = (Noesis::Gui::FrameworkElement*)mUIRoot;
Noesis::Gui::FrameworkElement* p1_root = (Noesis::Gui::FrameworkElement*)mPlugin1Root;
stack_ = NsStaticCast<StackPanel*> (main_root->FindName("RootGridLeftMenus"));
stack_->GetChildren()->Add(p1_root); <--- this does not work. Code: Select all
<UserControl 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"
mc:Ignorable="d"
x:Name="UserControlP1"
d:DesignWidth="100" d:DesignHeight="67">
<Grid x:Name="LayoutRoot">
<Button x:Name="Button1" Content="Button" HorizontalAlignment="Center" Width="100"
VerticalAlignment="Top" Height="30" d:LayoutOverrides="VerticalAlignment"/>
<Button x:Name="Button2" Content="Button" HorizontalAlignment="Center" Margin="0,37,0,0"
Width="100" VerticalAlignment="Top" Height="30"/>
</Grid>
</UserControl>Thanks.