首页 文章

是否可以使用Xaml设计器或智能感知与Xamarin.Forms?

提问于
浏览
41

Xamarin 3.0引入了Xamarin.Forms,这是一个功能强大的UI抽象,允许开发人员轻松创建可在Android,iOS和Windows Phone上共享的用户界面 .

它似乎非常强大,但我面临一些创建UI的困难,因为Xamarin.Forms带有40多个控件 . 如果没有intellisense或极简主义设计师,搜索官方文档中的所有属性或浏览c#代码会相当适得其反 .

默认的Xaml teamplate就像这样,在没有任何帮助的情况下添加新控件显然不是一件容易的事 .

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                       x:Class="App1.Class1">
    <Label Text="{Binding MainText}"  VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>

那么有没有机会在Xaml中使用intellisense或使用Xaml设计器?

9 回答

  • 18

    Xamarin.Forms 没有图形设计师(但是?) . intellisense有两部分:

    • 引用xaml元素标记为x:Xamarin.Studio和VisualStudio中 works 后面的代码中的名称

    • Xaml元素和属性的完成在Xamarin.Studio中有效,并且很快就会支持完成属性值 . 不幸的是,VisualStudio中的Xaml智能感知现在不起作用 . 但问题是众所周知的,并且研究了解决方案 .

  • 0

    我在PCL中使用Xamarin.Forms Intellisense扩展而不是SAP取得了成功 .

    enter image description here

  • 6

    Intellisense已经以第一种形式发布,更多信息请点击此处:

    Mobile Essentials: Productivity Tools for Mobile Developers

  • 0

    Xamarin Studio 6.1包含一个XAML预览器:

    enter image description here

    它并不完美,但是作为“预览”版本在iOS和Android上以不同的分辨率呈现您的XAML,包括不同的方向 .

    需要注册视频:https://brax.tv/lesson/xamarin-forms-hello-xaml-previewer/

    Xamarin Evolve Videos @ https://evolve.xamarin.com

    (此帖发布时的官方Evolve视频尚未在线)

  • 5

    如果您有Resharper 9,那么intellisense在Visual Studio中工作,具有Clint Landry提到的Xamarin.Forms Intellisense扩展 .

  • 4

    一家第三方公司正在开发一款名为UI Sleuth的Xamarin.Forms Designer .

    他们仍处于秘密模式,但已发布了几个演示视频:

    我推荐following the Lead Architect on Twitter . 这是他们发布最新的UI Sleuth更新的地方!

  • 1

    在VS上实现Intellisense所需的只是在安装时将.xsd文件中的Xamarin.Forms XAML模式放在visual studio的正确文件夹中 . 我想NuGet包/任务在安装时没有操作系统所需的访问权限(除非你将Visual Studio作为Admin运行并且硬编码路径运行到NuGet包安装任务中,这不是一个好主意) .

    我已经向Xamarin团队提出了同样的问题,他们回答说Intellisense还有未来的更新和未来的设计师(不知道多久,即使是alpha / beta Channels 的更新) .

    希望能帮助到你...

  • 1

    我刚刚在Xamarin Evolve 2016大会上宣布了一条关于Xamarin.Forms Designer的推文

    与此同时,您可以使用Windows Phone设计器和转换器来吐出Xamarin.Forms标记,请参阅:http://www.gui-innovations.com/Blog%20Posts/windows-phones-forms-to-xamarin-forms.html

    该工具也与其他相关工具一起提及:https://github.com/MvvmCross/MvvmCross-Forms/wiki/XAML-Tools-for-Xamarin

  • 0

    enter image description here

    我创建了两个视频,介绍了如何使用Xamarin Studio的新XAML预览器:

    Intro:

    Using Design Data:

    Design Data with ViewModelLocator:

    涉及的代码示例:

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
            x:Class="STLBrews.Mobile.BreweriesPage"     
            xmlns:vm="clr-namespace:STLBrews.ViewModels;assembly=STLBrews.ViewModels" 
            BindingContext="{x:Static vm:ViewModelLocator.BreweriesVM}">
        <ContentPage.Content>
            <ListView
                ItemsSource="{Binding Items}" >
                <ListView.ItemTemplate> 
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                <Image Source="{Binding LogoUrl}"/>
                                <StackLayout Orientation="Vertical" Spacing="0" VerticalOptions="Center">
                                    <Label Text="{Binding Name}" FontAttributes="Bold"/>
                                    <Label Text="{Binding Description}" FontSize="10"/>
                                </StackLayout>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </ContentPage.Content>
    </ContentPage>
    

相关问题