gpt4 book ai didi

wpf - 页面只能有 Window 或 Frame 作为父级

转载 作者:行者123 更新时间:2023-12-05 02:22:02 34 4
gpt4 key购买 nike

我只想在 WPF 页面之间切换,但出现上述错误:Page can have only Window or Frame as parent。这是我的代码

Imports System.Windows.Forms

公开课第1页

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文件代码

<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>

请指导我做错了什么?

最佳答案

根据名称 Page1,我假设它是一个页面。在 Page1 中放置一个 Frame,并将 Page2 加载到 Frame 中。

关于wpf - 页面只能有 Window 或 Frame 作为父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31358404/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com