Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page can have only Window or Frame as parent

Tags:

vb.net

wpf

I just want to switch between WPF pages, but getting above mentioned error:Page can have only Window or Frame as parent. here is my code

Imports System.Windows.Forms

Public Class Page1

Private Sub btn1_Click(sender As Object, e As RoutedEventArgs) Handles btn1.Click
    Try

        Dim dd As New Page2


        Me.Content = dd
        Me.txt1.Text = (dd.txt10.Text)
    Catch ex As Exception

        txt1.Text = ex.Message
    End Try

xaml file code

<Page x:Class="Page2"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  mc:Ignorable="d" 
  d:DesignHeight="300" d:DesignWidth="300"
  Title="Page2">
<Grid>

    <Button x:Name="button1" Content="Button" HorizontalAlignment="Left" Margin="163,62,0,0" VerticalAlignment="Top" Width="101" Height="55"/>
    <TextBox x:Name="txt10" HorizontalAlignment="Left" Height="23" Margin="38,81,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>

</Grid>

please guide me what i am doing wrong?

like image 942
Sonia Rehman Avatar asked Oct 30 '25 13:10

Sonia Rehman


1 Answers

Based on the name Page1 I assume it is a Page. Put a Frame in Page1 and load Page2 into the Frame.

like image 141
paparazzo Avatar answered Nov 02 '25 02:11

paparazzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!