c# - Binding method to button in WPF -


I have this console application that I want to do now in a WPF application. I'm new to WPF, so I'm not sure where to go from here. Currently I have the following functions to start a server:

  public static zero startArticle (string [] prefix) {HttpListener listener = new HttpListener (); If (prefix == faucet) prefix length == 0) throwing new logic expression ("prefix"); Forex (string in prefixes) {listener.Prefixes.Add ("http: //" + s + "/"); } Listenener.Start (); Console.WriteLine ("\ nListening ..."); Listner. Bangagat Contex (new asynchronous callback (audience query), listener); }  

Now I want to be able to do this in WPF with a button click I already have the following in my MainWindow.xaml.cs, but I started StartSistverButton_Click in my StartListening ( ) How can I use a sign of tie by the method I am using ICDomand, but it looks like a very complex solution to a very simple problem.

  public partial square main window: window {public key window () {InitializeComponent (); Try {IP Address [] addrs = Array.FindAll (Dns.GetHostEntry (string.Empty) .AddressList, a => a.AddressFamily == Address Family.Inter Network); ServerOutputTextBox.AppendText ("Your IPv4 address is:"); Foreign Currency (IP address address in address) {Server Optical Textbox. Append text (eder.tostring ()); } // Automatically set the IP address string [] ips = addrs.Select (ip = & gt; ip.ToString ()). ToArray (); (IPS) Response.StartListening; } Hold (exception e) {message box. Show (E. Message); }} Private Zero StartServerButton_Click (Object Sender, RoutedEventArgs E) {}  

Your code, After the window is loaded, the IPs are not changed. Make it private and use it in the handler click on the button:

  public partial class main window: window {private string []; Public Manvindo () {Initialization (); Try {IP address [] addrs = Array.FindAll (Dns.GetHostEntry (string.Empty) .AddressList, a => a.AddressFamily == Family.Inter Network); ServerOutputTextBox.AppendText ("Your IPv4 address is:"); Foreign Currency (IP address address in address) {Server Optical Textbox. Append text (eder.tostring ()); } // Automatically set IP address ips = adserver Select (IP => IP toString ()). ToArray (); } Hold (exception e) {message box. Show (E. Message); }} Private Zero StartServerButton_Click (Object Sender, RoutedEventArgs e) {Response.StartListening (ips); }  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -