博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wp7设置浏览器主页
阅读量:7063 次
发布时间:2019-06-28

本文共 1836 字,大约阅读时间需要 6 分钟。

    <!--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();
        }
     

 

转载地址:http://wwill.baihongyu.com/

你可能感兴趣的文章
GitHub推出更多课程
查看>>
InfoQ播客:Tal Weiss谈JVM的可观测性、插桩、以及字节码操作
查看>>
独家!支付宝小程序技术架构全解析
查看>>
1100名达摩院“扫地僧”加持,阿里云的下一个十年
查看>>
python学习笔记-类对象的信息
查看>>
Java多线程(4):使用线程池执行定时任务
查看>>
poj 2192 Zipper
查看>>
DELL服务器硬件信息采集SHELL脚本
查看>>
英语每日听写练习 Day 19
查看>>
velocity的一些用法
查看>>
Aisino 金税盘 pass throught
查看>>
界面代码分离的软件设置界面设计
查看>>
第十五周学习进度条
查看>>
3G美餐:谁有红苹果?
查看>>
ASP.NET中Html.Partial和Html.Action的一个区别
查看>>
VMM系列之添加Hyper-V群集主机到VMM服务器
查看>>
Java开源报表JasperReport、iReport4.5.1使用详解(二)
查看>>
使用必应查询接口开发搜索工具:反查一个IP上的旁站
查看>>
RHCE 学习笔记(7) 进程管理
查看>>
Lync Server 2010迁移至Lync Server 2013故障排错 Part 2: Lync Server 迁移后部分用户无法移池问题...
查看>>