将数据从表单移动到表单Silverlight WP7表达式混合 - SketchFlow

时间:2012-02-26 14:57:02

标签: c# silverlight windows-phone-7

我已经尝试了一整天,有点放弃了研究 我基本上需要做的是在form2上选择此按钮后更新第一页上的信息

我做的是这个:

private void btnContinue_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // TODO: Add event handler implementation here.

            Screen_1 S1 = new Screen_1();
            S1.CO2.Text = "TEXT";
            S1.CO3.Visibility = Visibility.Visible;
            //NavigationService.Source=new Uri("/Screen_1.xaml", UriKind.Relative);
            //NavigationService.Navigate(new Uri("/Screen_1.xaml", UriKind.Relative));

        }

由于某些原因,如果我在按钮后面有代码,它不会更新和导航表达式混合不起作用:(

更新

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Expression.Prototyping.WindowsPhone.Mockups;
using System.Windows.Navigation;

namespace Analyser2_v1Screens
{
    public partial class Select : WindowsPhoneChrome
    {
        Screen_1 formOne = null;

        public Select()
        {
            // Required to initialize variables
            InitializeComponent();

        }

        public Select(Screen_1 formOneInstance)
        {
            // Required to initialize variables
            InitializeComponent();
            formOne = formOneInstance;

        }


        private void clickedC(object sender, System.Windows.RoutedEventArgs e)
        {
            // TODO: Add event handler implementation here.
            //Screen_1 S1 = new Screen_1();
            //  S1.CO2.Content = "This is string content of a Button";
            //  S1.CO3.Visibility = Visibility.Visible;
            //  S1.test1.Text = "Tet";
            //NavigationService.Source=new Uri("/Screen_1.xaml", UriKind.Relative);
            //NavigationService.Navigate(new Uri("/Screen_1.xaml", UriKind.Relative));

            formOne.test1.Text ="test";


        }


    }
}

不够完美

1 个答案:

答案 0 :(得分:1)

请分享您的代码片段。从我对你的问题的理解,你可以将表单1的实例传递给2的构造函数,并从那里改变form1的元素。

// form 1 var
FormOne formOne = null;

// form 2's constructor
public FormTwo(FormOne formOneInstance)
{
   /*initialization etc*/
   formOne = formOneInstance;
}

// some method to alter an element in form 1
private void AlterSomthingInFormOne()
{
   formOne.SomeString = "Whatever value you'll need";
}