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

时间:2014-06-10 19:35:32

标签: c# xaml xamarin xamarin.forms

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 个答案:

答案 0 :(得分:18)

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

  • 引用xaml元素标记为x:Xamarin.Studio和VisualStudio中工作后面的代码中的名称
  • Xaml元素和属性的完成在Xamarin.Studio中有效,并且很快就会支持完成属性值。不幸的是,VisualStudio中的Xaml智能感知现在不起作用。但问题是众所周知的,并且正在研究解决方案。

答案 1 :(得分:6)

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

enter image description here

答案 2 :(得分:5)

Intellisense已经以其第一种形式发布,更多信息来自:

Mobile Essentials: Productivity Tools for Mobile Developers

答案 3 :(得分:4)

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

enter image description here

这不是完美的,而是作为预览&#34; release在iOS和Android上以不同的分辨率渲染你的XAML,包括不同的方向。

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

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

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

答案 4 :(得分:1)

如果你有Resharper 9,那么intellisense在Visual Studio中可以使用Clint Landry提到的Xamarin.Forms Intellisense扩展。

答案 5 :(得分:1)

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

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

我建议following the Lead Architect on Twitter。这是他们发布最新的UI Sleuth更新的地方!

答案 6 :(得分:0)

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

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

希望它有所帮助...

答案 7 :(得分:0)

我刚刚在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

答案 8 :(得分: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>