如何通过在WP7和WP8中单击来更改TextBlock的Text属性? [英] How to change Text property of a TextBlock by click in WP7 and WP8?

查看:81
本文介绍了如何通过在WP7和WP8中单击来更改TextBlock的Text属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是WP8的初学者。

我有问题...

例如:

我的Windows Phone应用程序中有2页,第一页上有3个按钮,第二页上有一个TextBlock控件。

如何更改其文本属性第二页点击第一页上的按钮?


例如,如果我点击:


button1 [first page] - >文本框的文本是"你好"。 [第二页]


button2 [第一页] - >文本框的文本是"詹姆斯"。 [第二页]


等....



我只知道如何更改文字时控件在同一页面上:

  private void button1_Click(object sender,RoutedEventArgs e)
{
textBlock1.Text =" Hello!" ;;
}

解决方案


<首先,你怎么能看到两种形式。 Anway,您可以将参数从一个页面发送到另一个页面。

 NavigationService.Navigate(new Uri(" /newpage.xaml?key = value",Urikind) .Relative)); 




 protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationContext.QueryString.ContainsKey(" key"))
{
string val = NavigationContext.QueryString [" key"];
//等...
}




I'm a beginner in WP8.
I have a problem...
For Example:
I have 2 pages in my windows phone application, and on first page I have 3 buttons and on second page I have a TextBlock control.
How can I change its text property on the second page by clicking the buttons which are on the first page?

Foe example if i click:

button1[first page] --> text of textbox is "Hello" [second page]

button2[first page] --> text of textbox is "James" [second page]

etc....

I only know how to change text when the controls are on the same page:

private void button1_Click(object sender, RoutedEventArgs e)
{
    textBlock1.Text= "Hello!";
}

解决方案

Hi,

First thing, How can you see two forms together. Anway, You can send a parameters from one page to another page.

NavigationService.Navigate(new Uri("/newpage.xaml?key=value", Urikind.Relative));


protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (NavigationContext.QueryString.ContainsKey("key"))
    {
         string val = NavigationContext.QueryString["key"];
         // etc ...
    }



这篇关于如何通过在WP7和WP8中单击来更改TextBlock的Text属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆