Setting Datacontext of viewmodel not in constructor
<p>I have a <code>WPF</code> application using <code>mah metro</code> where I have a <code>tab control</code> </p>

<pre><code>  &lt;Controls:MetroAnimatedTabControl Grid.Column="3" Grid.Row="1" SelectedIndex="{Binding SelectedTabIndex,Mode=TwoWay}"&gt;
        &lt;TabItem Header="Manual Control"&gt;
            &lt;view:ManualControlView DataContext="{Binding ManualControlViewModel}"/&gt;
        &lt;/TabItem&gt;
        &lt;TabItem Header="Set up"&gt;
            &lt;view:SetupView DataContext="{Binding SetupViewModel}"/&gt;
        &lt;/TabItem&gt;
    &lt;/Controls:MetroAnimatedTabControl&gt;
</code></pre>

<p>I am setting the <code>datacontext</code> in the <code>TabItem</code>.  I am creating a <code>TcpCllient</code> and passing that reference to each <code>ViewModel</code>.  When I am doing this in the constructor everything works fine.</p>

<pre><code>  public MainViewModel()
    {
        _client = new TcpClient(IP_ADDRESS, PORT);
        _client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
        _master = ModbusIpMaster.CreateIp(_client);

        ManualControlViewModel = new ManualControlViewModel(_master);
        SetupViewModel = new SetupViewModel(_master);

    }
</code></pre>

<p>However, I don't wish to create the <code>TcpClient</code> in the constructor.  Instead I wish to create it when I hit a "Connect" button in my window.  However, when I click my "Connect" button to execute a <code>OnConnect</code> method to do this my views are not getting set to the <code>datacontext</code>.</p>

<pre><code>  private void OnConnect(object obj)
    {
        _client = new TcpClient(IP_ADDRESS, PORT);
        _client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
        _master = ModbusIpMaster.CreateIp(_client);
        Connected = _client.Connected;

        ManualControlViewModel = new ManualControlViewModel(_master);
        SetupViewModel = new SetupViewModel(_master);          

        StartReadingInfo();
    }
</code></pre>

<p>Is it possible to accomplish this?</p>