为了账号安全,请及时绑定邮箱和手机立即绑定

我在将xaml用于xamarin forns项目时遇到错误,并且在呈现控件时发生异常

我在将xaml用于xamarin forns项目时遇到错误,并且在呈现控件时发生异常

C#
蝴蝶不菲 2022-08-20 17:43:41
在此输入图像描述我正在制作一个应用程序,该应用程序仅使用按钮请求URL,并且我想在无法正常工作的WebView上显示URL的内容<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://xamarin.com/schemas/2014/forms"             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             xmlns:local="clr-namespace:SAT"             x:Class="SAT.MainPage">    <StackLayout VerticalOptions="Center"                 BackgroundColor="#3C3838">        <Button Text="On\\Off"                 BackgroundColor="#6FD761"                Margin="70,240,70,0"                x:Name="ToggleRelay1"                Clicked="ToggleRelay1_Clicked"/>        <Button Text="On\\Off"                 BackgroundColor="#6FD761"                Margin="70,20,70,0"                x:Name="TggleRelay2"                Clicked="TggleRelay2_Clicked"/>        <Button Text="Having Trouble ? connect Manualy"                 BackgroundColor="#00D06262"                Margin="0,250,0,0"/>    </StackLayout>    <WebView x:Name="TestWebView"             HeightRequest="100"             WidthRequest="100"/></ContentPage>
查看完整描述

2 回答

?
倚天杖

TA贡献1828条经验 获得超3个赞

内容页只能有一个直接子项,因此您的 xaml 代码应如下所示:


  <?xml version="1.0" encoding="utf-8" ?>

  <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

         xmlns:local="clr-namespace:SAT"

         x:Class="SAT.MainPage">


<StackLayout VerticalOptions="Center"

             BackgroundColor="#3C3838">

    <Button Text="On\\Off" 

            BackgroundColor="#6FD761"

            Margin="70,240,70,0"

            x:Name="ToggleRelay1"

            Clicked="ToggleRelay1_Clicked"/>


    <Button Text="On\\Off" 

            BackgroundColor="#6FD761"

            Margin="70,20,70,0"

            x:Name="TggleRelay2"

            Clicked="TggleRelay2_Clicked"/>


    <Button Text="Having Trouble ? connect Manualy" 

            BackgroundColor="#00D06262"

            Margin="0,250,0,0"/>




<WebView x:Name="TestWebView"

         HeightRequest="100"

         WidthRequest="100"/>

    </StackLayout>

   </ContentPage>


查看完整回答
反对 回复 2022-08-20
?
PIPIONE

TA贡献1829条经验 获得超9个赞

内容页不支持多个项目。考虑将 Web 视图放入 StackLayout 中,或者(如果需要按钮来覆盖 Web 视图)使用 AbsoluteLayout。


查看完整回答
反对 回复 2022-08-20
  • 2 回答
  • 0 关注
  • 130 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号