title: Passing string/int to label with c# in wpf
body: <p>I'm making a TCP client and would like it to show the IP and port that is been used.</p>
  
  <p>I have two labels that I would like to be filled with the text of the ip and port been used, these in the code are called serverip_lbl and portno_lbl.</p>
  
  <p>You can see I have tried two different ways to do this, neither give me an error and allow me to compile. However, the labels show nothing on the interface.</p>
  
  <pre><code>namespace client
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
          }
  
          TcpClient client = new TcpClient(); // New instance of TcpClient class of the .Net.Sockets
          string ipaddress = "127.0.0.1";
          int port = 8888;
  
          private void MainWindow_Load(object sender, EventArgs e)
          {
              client.Connect(ipaddress, port); // IP, Port
              serverip_lbl.Content += "" + ipaddress;
              portno_lbl.Content = port;
          }
      }
  }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="client.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:client"
      mc:Ignorable="d"
      Title="MainWindow" Height="500" Width="400"&gt;
  &lt;Grid&gt;
      &lt;Label x:Name="titleclient_txt" Content="Client" Margin="10,10,0,0" VerticalAlignment="Top" FontWeight="Bold" FontSize="18.667" HorizontalAlignment="Left" FontStyle="Italic" d:IsLocked="True"/&gt;
      &lt;Label x:Name="demotitle_txt" Content="Sending a message" HorizontalAlignment="Right" Margin="0,50,87,0" VerticalAlignment="Top" FontSize="24" FontWeight="Bold" d:IsLocked="True"/&gt;
      &lt;Label x:Name="server_lbl" Content="Server IP:" HorizontalAlignment="Left" Margin="74,106,0,0" VerticalAlignment="Top" d:IsLocked="True"/&gt;
      &lt;Label x:Name="serverip_lbl" Content="" HorizontalAlignment="Left" Margin="155,106,0,0" VerticalAlignment="Top" Width="150" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/&gt;
      &lt;Label x:Name="port_lbl" Content="Port:" HorizontalAlignment="Left" Margin="74,146,0,0" VerticalAlignment="Top" d:IsLocked="True"/&gt;
      &lt;Label x:Name="portno_lbl" Content="" HorizontalAlignment="Left" Margin="155,146,0,0" VerticalAlignment="Top" Width="150" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/&gt;
      &lt;Label x:Name="message_lbl" Content="Message:" HorizontalAlignment="Left" Margin="74,199,0,0" VerticalAlignment="Top" d:IsLocked="True"/&gt;
      &lt;TextBox x:Name="message_txt" HorizontalAlignment="Left" Height="70" Margin="74,230,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="250"/&gt;
      &lt;Button x:Name="send_button" Content="Send" HorizontalAlignment="Left" Margin="155,344,0,0" VerticalAlignment="Top" Width="75"/&gt;
      &lt;Button x:Name="request_button" Content="Request message" HorizontalAlignment="Left" Margin="125,380,0,0" VerticalAlignment="Top" Width="137"/&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>