在WPF VB.Net中传递数据从一个页面到另一个页面

3

我有两个打开的WPF页面,我想将Page2中的"textbox3.text"发送到Page1中的"textbox1.text"

在VB中很容易:

page1.textbox1.text = texbox3.text

但我不知道如何在WPF中实现这一点。

1个回答

1
我认为你可以在Page1中创建一个属性,该属性包含TextBox中的值。
Public ReadOnly Property TextBox1Value() As String
    Get
        Return theFirstTextBox.Text
    End Get
End Property

获得这个值并将其传递给构造函数中的Page2

Public Sub New(ByVal value As String)

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    theSecondTextBox.Text = value
End Sub

Private Sub CreatePage2Method()
    Dim page As Page2 = New Page2("BlaBlaBla")
    NavigationService.Navigate(page)
End Sub

祝你好运!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接