c# - WPF - How can I access to elements in different tabs that are defined in separated XAMLs? -



c# - WPF - How can I access to elements in different tabs that are defined in separated XAMLs? -

well, situation this: have wpf project contains tabcontrol 2 tabitems. 1 tab contains textblock, , other 1 has textbox , button. want accomplish when pressing button, text within textbox of sec tab appears in textblock of first tab.

it should easy duty, i'm stuck because have each tab designed in separated xaml (and need maintain way), , have mainwindow.xaml:

<window x:class="tabsusercontrol.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:tabsusercontrol" x:name="root" title="mainwindow" height="350" width="525"> <grid> <tabcontrol name="tabctrl" horizontalalignment="left" height="210" verticalalignment="top" width="366" margin="89,47,0,0"> <local:usertabcontrol1 name="tab1"/> <local:usertabcontrol2 name="tab2"/> </tabcontrol> </grid> </window>

all elements have assigned name, how can access them write methods in .cs file of xaml sec tab?

thanks in advance!

you can add together binding text-property of each textbox, two-way-mode. if button pressed: set value of first propert second.

the properties like:

private string text1; public string text1 { get{return this.text1;} set{ this.text1 = value; onpropertychanged("text1");} } private string text2; public string text2 { get{return this.text2;} set{ this.text2 = value; onpropertychanged("text2");} }

in click-event (or executecommand) of button have do:

text1 = text2;

that's it

c# wpf user-controls tabs

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -