wp7 용 웹 브라우저 앱을 만들었습니다. 거기에 응용 프로그램 표시 줄 메뉴 항목에 약 6 탭을 추가했습니다. 하지만 이제는 사용자 정의 컨트롤 페이지에서 6 개의 탭을 따로 사용하고 탭 2 또는 탭을 클릭하면 현재와 같이 작동합니다.이 탭에 사용자 정의 컨트롤을 사용하는 방법
에서 MainPage.xaml
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox x:Name="UrlTextBox"
KeyDown="UrlTextBox_KeyDown" />
<Grid x:Name="BrowserHost"
Grid.Row="1" />
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="1"
Click="TabMenuItem_Click" />
<shell:ApplicationBarMenuItem Text="2"
Click="TabMenuItem_Click" />
<shell:ApplicationBarMenuItem Text="3"
Click="TabMenuItem_Click" />
<shell:ApplicationBarMenuItem Text="4"
Click="TabMenuItem_Click" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
MainPage.xaml.cs를
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 < 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);
}
}
아래 브라우저가있다처럼.
아무도 도와 줄 수 있습니까? 당신의 도움을 주셔서 감사합니다!
아니, 나는 그것을 피벗 싶지 않아. 나는 위의 wp7 IE 또는 UC 브라우저가 새 탭을 만드는 데 사용하는 위와 같은 것을 원합니다. 내 게시물에 이미지를 추가했습니다. –
네이티브 브라우저가이 UC를 지원하지 않습니다. 이 사용자 지정 UC를 만들고 단추/항목을 클릭하여 해당 컨트롤 을 활성화하거나 팝업 컨트롤을 사용하여 비슷한 fassion에서 디자인 할 수 있습니다. –
나는 내 자신의 사용자 정의 컨트롤을 만들어야하지만 새로운 기능을 알고 있습니다. 사용자 컨트롤, 그 이유는 그냥 그 거래 또는 위의 비슷한 샘플이 필요합니다. –