c# - Set WPF Textbox Value in innerclass -
it may bit of noob question i'm not experienced programmer.
i using wcf in combination wpf create chatroom gui. problem use callbackhandler set value of textbox incoming messages. because innerclass cannot call textbox. know solution this?
namespace wpfclient public partial class mainwindow : window { service1client s; public mainwindow() { initializecomponent(); instancecontext site = new instancecontext(new callbackhandler()); s = new service1client(site); } private void button_click(object sender, routedeventargs e) { message m = new message(); m.content = txtmessage.text; m.user = txtname.text; s.sendmessage(m); } public class callbackhandler : iservice1callback { public void sendmessagetoclients(message m) { //i call alrdy generated textbox here set value, txtmessageall.text("setting text"); } } }
}
thanks!
as callbackhandler custom class, can pass textbox mainwindow class through parameterised constructor, while creating object. reference being passed can change text of textbox through callback handler class also.
public class callbackhandler { public textbox textvalue { get; set; } callbackhandler(textbox tb) { this.textvalue = tb; } public void sendmessagetoclients(message m) { this.textvalue.text="some_message"; //i call alrdy generated textbox here set value, txtmessageall.text("setting text"); } }
and mainwindow class
instancecontext site = new instancecontext(new callbackhandler(txtboxmessageall));
where "txtboxmessageall" textbox present in xaml page.
Comments
Post a Comment