【发布时间】:2019-09-30 21:41:50
【问题描述】:
如何在其他页面上写入TextBlock?
到目前为止,它仅适用于同一页面上的TextBlocks。async 函数在 Page_1 中。 TextBlock 位于 Page_2。
public async void Serial()
{
string rxBuffer;
//code
//code
//code
while (true)
{
textblock_DebugRx_Gas_live.Text = rxBuffer;
}
}
【问题讨论】:
-
我想我们需要更多详细信息,但也许您可以尝试使用 ApplicationData:docs.microsoft.com/en-us/windows/uwp/design/app-settings/…
-
只需要创建一个公共类为 -
CommonClass并将静态字符串对象声明为 -txtObj然后在Page_1上将值传递给公共类作为 -CommonClass.txtObj = "your string"然后Page_2load 将值传递给TextBlockas -txtBlock.text = CommonClass.txtObj也可以从Frame.Navigate传递数据 -
@TonicLoyal:你在
Page_1中是否有对Page_2的引用,或者你试图访问的Page_2在哪里?
标签: c# asynchronous uwp textblock