Search code examples
c#windows-store-appswinrt-xaml

Change Textbox text from another frame(container)


I see here lot of similar question, but I still not find answer that help me in situation.

I have two frame(lets say FrameChild), one is "in" another(practically FrameChild is in this frame, lets say FrameMain).

When I insert all parameters in FrameChild and tap on button witch is on bottom of FrameMain I call method that return string... Now when i get string i need to change textbox text in FrameChild

I have tray many way.

First idea was something like:

FrameChild frm = new FrameChild;
frm.textbox.text = "somestring";

But nothing happen. Than i thing use some property.

in FrameChield:

public string setTicNo
{
     set
        {
           textBox.Text = value;  
        }
    }

in FrameMain: FrameChild frm = new FrameChild; frm.setTicNo = "somestring";

When i debbuging I get value, but textbox still is empty...

On the end I try to bind textbox text on setTicNo;

public string setTicNo
{
     get
        {
            return setTicNo;
        }
     set
        {
           setTicNo = value;  
        }
 }

Xaml:

Text = {Binding setTicNo, Mode=TwoWay,UpdateSourceTrigger=Explicit}

(here i try use more bindings, but every time i get infinite loop.

Please help , I not have more ideas..

Thanx


Solution

  • Did you try building a single view model and bind it to both frames, if it was passed by ref which is the default it will change the value once you do.

    A side note implement a INOTIFYPROPERTYCGANGED in the View model