wp7设置浏览器主页

 2023-09-10 阅读 17 评论 0

摘要:<!--LayoutRoot 是包含所有页面内容的根网格--> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height

    <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>


        <!--TitlePanel 包含应用程序的名称和页标题-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="启动Web浏览器" Margin="9,-7,0,0" FontSize="50"/>
        </StackPanel>


        <!--ContentPanel - 在此处放置其他内容-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBlock Height="40" HorizontalAlignment="Left" Margin="38,57,0,0" Name="textBlock1" Text="请输入URL:" VerticalAlignment="Top" Width="286" FontSize="28"/>
            <TextBox Text="www.baidu.com" Height="72" HorizontalAlignment="Left" Margin="12,122,0,0" Name="txtUrl" VerticalAlignment="Top" Width="394" />
            <Button Content="通过Uri对象设置并启动" Height="79" HorizontalAlignment="Left" Margin="12,222,0,0" Name="button1" VerticalAlignment="Top" Width="394" Click="button1_Click" />
            <Button Content="通过字符串设置并启动" Height="79" HorizontalAlignment="Left" Margin="9,323,0,0" Name="button2" VerticalAlignment="Top" Width="394" Click="button2_Click" />
            <TextBlock TextWrapping="Wrap" Height="143" HorizontalAlignment="Left" Margin="19,464,0,0" Name="textBlock2" Text="设置浏览器的主页,这两种方法都可以 第一种格式为:hhtp://www.bai.com      第二种方法为:www.baidu.com" VerticalAlignment="Top" Width="437" FontSize="25" />
        </Grid>

    </Grid>

后台代码:



        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // 通过Uri对象设置  
            try
            {
                WebBrowserTask wt = new WebBrowserTask();
                wt.Uri = new Uri(txtUrl.Text, UriKind.Absolute);
                wt.Show();
            }
            catch { MessageBox.Show("格式不正确,请注意格式!!!"); }
        }


        private void button2_Click(object sender, RoutedEventArgs e)
        {
            // 通过字符串设置  
            WebBrowserTask wt = new WebBrowserTask();
            wt.URL = txtUrl.Text;
            wt.Show();
        }

     

华为浏览器不能设置主页, 

转载于:https://www.cnblogs.com/snake-hand/archive/2013/06/10/3131026.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/38602.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息