Note that there are some explanatory texts on larger screens.

plurals
  1. POSet textbox focus when tabItem selected in WPF vb
    primarykey
    data
    text
    <p>New to WPF, aware their are many questions on this already but none have worked. I would like a text box within a tab to get focus when the tab has been selected.</p> <p>currently have </p> <pre><code>Private Sub TabControl1_Event(sender As Object, e As System.Windows.Controls.SelectionChangedEventArgs) _Handles TabControl1.SelectionChanged UpdateLayout() 'tried me.show() as well If TabControl1.SelectedIndex = 0 Then i = i + 1 Title = "selected" + Convert.ToString(i) UserBox.Focus() End If End Sub </code></pre> <p>the i increment and and title change are their just to see if the if loop is being entered and apparently it is, however the textbox (the only other control in the application) only gets focus when the program first starts.</p> <p>As I said I have seen lots of the other questions <em>similar</em> to this here but either they are not exactly the same or just do not work. I am using vb.net in a WPF application. It seems like this should be very simple but cant for the life of me figure it out</p> <p>It would be nice if this could be done via a tabItem event rather than a tabControl event also.</p> <p>Update: IDK if it matters but I have seen others posting it and so this is my XAML</p> <pre><code>&lt;Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Burn In" Height="350" Width="525"&gt; &lt;TabControl Height="Auto" Name="TabControl1" Width="Auto"&gt; &lt;TabItem Header="User" Name="UserTab"&gt; &lt;Grid&gt; &lt;TextBox Height="25" HorizontalAlignment="Center" Margin="0" Name="UserBox" VerticalAlignment="Center" Width="250" AcceptsReturn="True" /&gt; &lt;/Grid&gt; &lt;/TabItem&gt; &lt;TabItem Header="DUT" Name="DutTab"&gt; &lt;Grid /&gt; &lt;/TabItem&gt; &lt;TabItem Header="Rack" Name="RackTab"&gt; &lt;Grid /&gt; &lt;/TabItem&gt; &lt;TabItem Header="Programs" Name="ProgTab"&gt; &lt;Grid /&gt; &lt;/TabItem&gt; &lt;/TabControl&gt; &lt;/Window&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload