Hi folks
I wrote a program which opens my second UserControl in the main window. The program runs in visual studio but the result doesn't work. I mean when you click on the button, it doesn't open the second window.
Any kindly help please?
Thanks.
What I have tried:
The code of MainWindow in XAML
<Window x:Name="TheMainWindow" x:Class="MainWindow"
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:SRT2Nuendo"
mc:Ignorable="d"
Title="MyMainWindow"
Width="1000"
Height="600"
WindowStartupLocation="CenterScreen"
HorizontalAlignment="Center"
VerticalAlignment="Center"
WindowStyle="None"
AllowsTransparency="True"
BorderThickness="3"
AllowDrop="False">
<Grid
<ContentControl x:Name="CC"/>
</Grid>
</Window>
The code of MainWindow in VB.NET
Class MainWindow
Sub New()
InitializeComponent()
CC.Content = New UserControlMain1
End Sub
End Class
This is code of UserControlPlatform in XAML
<UserControl x:Name="ucMain1" x:Class="UserControlMain1"
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:MainWindow"
mc:Ignorable="d"
Width="1000"
Height="600"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="3"
AllowDrop="False">
<Grid
<Button x:Name="btnOpenNewUC"/>
</Grid>
</UserControl>
This is code of UserControlMain1 in VB.NET
Public Class UserControlMain1
Private Sub btnOpenNewUC_Click(sender As Object, e As RoutedEventArgs) Handles btnOpenNewUC.Click
Dim NewUC = New MainWindow
NewUC.CC.Content = New UserControlMain2
End Sub
End Class
This is Code of UserControlMain2 in XAML
<UserControl x:Name="ucMain2" x:Class="UserControlMain2"
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:MainWindow"
mc:Ignorable="d"
Width="1000"
Height="600"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="3"
AllowDrop="False">
<Grid
<Label x:Name="lbHello" Text="HELLO WORLD!"/>
</Grid>
</UserControl>