我使用XAML的xamarin forns项目时得到一个错误,我越来越而呈现控件发生异常

问题描述 投票:0回答:2

enter image description hereI想提出一个应用程序,只需申请使用按钮链接,我想在这是行不通的网页视图显示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>
c# xaml xamarin.forms
2个回答
1
投票

ContentPage不支持多个项目。考虑将Web视图进入StackLayout或者(如果你需要的按钮来覆盖Web视图)使用AbsoluteLayout。


1
投票

内容页只能有一个直接子让你的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>
© www.soinside.com 2019 - 2024. All rights reserved.