首页 > 解决方案 > 将 xaml 用于 xamarin forns 项目时出现错误,并且在呈现控件时出现异常

问题描述

在此处输入图像描述我正在制作一个应用程序,它只需使用按钮请求一个 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>

标签: c#xamlxamarin.forms

解决方案


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


推荐阅读