Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use the user control for these tabs
    text
    copied!<p>I have created a web browser app for wp7. In that i have added some 6 tabs in it in the application bar menu items. But now i want those 6 tabs in an user control page separately and if i click on tab 2 or any tab, it should work as it is now. </p> <p><strong>MainPage.xaml</strong></p> <pre><code>&lt;Grid x:Name="LayoutRoot"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBox x:Name="UrlTextBox" KeyDown="UrlTextBox_KeyDown" /&gt; &lt;Grid x:Name="BrowserHost" Grid.Row="1" /&gt; &lt;/Grid&gt; &lt;phone:PhoneApplicationPage.ApplicationBar&gt; &lt;shell:ApplicationBar&gt; &lt;shell:ApplicationBar.MenuItems&gt; &lt;shell:ApplicationBarMenuItem Text="1" Click="TabMenuItem_Click" /&gt; &lt;shell:ApplicationBarMenuItem Text="2" Click="TabMenuItem_Click" /&gt; &lt;shell:ApplicationBarMenuItem Text="3" Click="TabMenuItem_Click" /&gt; &lt;shell:ApplicationBarMenuItem Text="4" Click="TabMenuItem_Click" /&gt; &lt;/shell:ApplicationBar.MenuItems&gt; &lt;/shell:ApplicationBar&gt; &lt;/phone:PhoneApplicationPage.ApplicationBar&gt; </code></pre> <p><strong>MainPage.xaml.cs</strong></p> <pre><code>public partial class MainPage : PhoneApplicationPage { private const int NumTabs = 4; private int currentIndex; private string[] urls = new string[NumTabs]; private WebBrowser[] browsers = new WebBrowser[NumTabs]; public MainPage() { InitializeComponent(); ShowTab(0); } private void ShowTab(int index) { this.currentIndex = index; UrlTextBox.Text = this.urls[this.currentIndex] ?? ""; if (this.browsers[this.currentIndex] == null) { WebBrowser browser = new WebBrowser(); this.browsers[this.currentIndex] = browser; BrowserHost.Children.Add(browser); } for (int i = 0; i &lt; NumTabs; i++) { if (this.browsers[i] != null) { this.browsers[i].Visibility = i == this.currentIndex ? Visibility.Visible : Visibility.Collapsed; } } } private void UrlTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Uri url; if (Uri.TryCreate(UrlTextBox.Text, UriKind.Absolute, out url)) { this.urls[this.currentIndex] = UrlTextBox.Text; this.browsers[this.currentIndex].Navigate(url); } else MessageBox.Show("Invalid url"); } } private void TabMenuItem_Click(object sender, EventArgs e) { int index = Int32.Parse(((ApplicationBarMenuItem)sender).Text) - 1; ShowTab(index); } } </code></pre> <p><strong>Like the below browser has it.</strong> <img src="https://i.stack.imgur.com/O82eu.jpg" alt="enter image description here"></p> <p>Can anyone help me with this? Thanks for your help!</p>
 

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