简体   繁体   English

xaml预览器仅显示空白页

[英]xaml previewer showing only blank page

I have created simple xamarin form application in visual studio 2017.When i opening a xaml file with xaml previewer,the xaml previewer showing only blank page with text "XFPagerendererview" as attached screenshot.Please help 我已在Visual Studio 2017中创建了简单的xamarin表单应用程序。当我使用xaml预览器打开xaml文件时,xaml预览器仅显示空白页面,文本为“ XFPagerendererview”作为附件的屏幕截图。请帮助

Xaml File 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:App1"
             x:Class="App1.MainPage">

    <Label Text="Welcome to Xamarin Forms!" 
           VerticalOptions="Center" 
           HorizontalOptions="Center" />

    <StackLayout Spacing="20" Padding="50" VerticalOptions="Center">
        <Entry x:Name="user_id" Placeholder="Mail id"></Entry>
        <Entry x:Name="password" Placeholder="Password" IsPassword="True"></Entry>
        <Button Text="Log In" TextColor="White" BackgroundColor="##ff77D065" Clicked="NavigateButton_OnClicked"></Button>
    </StackLayout>

</ContentPage>

在此处输入图片说明

Since you didn't post the full code it is hard to say what is your exact problem, however I can spot some problems in your XAML: 由于您没有发布完整的代码,因此很难说出您的确切问题是什么,但是我可以在您的XAML中发现一些问题:

  1. Your page should contain only one root element but you have 2, Label and StackLayout . 您的页面应该只包含一个根元素,但是您必须包含2个LabelStackLayout So please set use a single view or a layout with child views. 因此,请设置使用单个视图或带有子视图的布局。 As a quick fix put your label inside the StackLayout or simply remove it, since it contains the default welcome message. 快速解决方案是将标签放入StackLayout或将其删除,因为它包含默认的欢迎消息。

  2. You have an invalid color, that should be #ff77D065 instead of ##ff77D065. 您有一个无效的颜色,应该是#ff77D065而不是## ff77D065。

XAML preview might not work that great, there are some alternatives that can be used for example Xamarin Live Player . XAML预览可能效果不佳 ,可以使用一些替代方法,例如Xamarin Live Player

PS: I would highly recommend to enable XAMLC so you will get notified about XAML exceptions while building and of course getting familiar with the XAML official documentation . PS:我强烈建议启用XAMLC,这样一来,您在构建XAML时会得到有关XAML异常的通知,当然您也应该熟悉XAML官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM