简体   繁体   中英

Is it possible to use a Xaml designer or intellisense with Xamarin.Forms?

Xamarin 3.0 introduced Xamarin.Forms , a powerful UI abstraction that allows developers to easily create user interfaces that can be shared across Android, iOS, and Windows Phone.

It seems very powerful but I'm facing a few difficulties to create UI as Xamarin.Forms comes with more than 40 controls. Without intellisense or a minimalist designer, it's fairly counter-productive to search for all properties in the official doc or by browsing c# code.

The default Xaml teamplate is like this, and it's clearly not trivial to add new controls without any help.

<?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>

So is there any chance to have intellisense inside Xaml or to use the Xaml designer ?

Xamarin.Forms does not come with a graphical designer (yet ?). As for intellisense there are 2 parts:

  • referencing xaml element tagged with x:Name in code behind works in both Xamarin.Studio and VisualStudio
  • Xaml completion of elements and attributes works in Xamarin.Studio, and support for completing attributes values is coming very soon. Unfortunately, intellisense for Xaml in VisualStudio does not work for now. But the problem is well known, and solutions are investigated.

I have had success with Xamarin.Forms Intellisense extension in a PCL but not SAP.

在此输入图像描述

Intellisense has been released in its first form, more information here:

Mobile Essentials: Productivity Tools for Mobile Developers

Xamarin Studio 6.1+ includes a XAML previewer:

在此输入图像描述

It is not perfect, but as a "preview" release does a decent job of rendering your XAML in different resolutions on iOS and Android, including different orientations.

A registration required video: https://brax.tv/lesson/xamarin-forms-hello-xaml-previewer/

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

(Official Evolve video at the time of this posting are not online yet)

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

A 3rd-Party company is developing a Xamarin.Forms Designer called UI Sleuth.

They are still in stealth-mode, but have posted a couple of demo videos:

I recommend following the Lead Architect on Twitter . This is where they are posting the latest UI Sleuth updates!

All that is needed to implement Intellisense on VS is have the Xamarin.Forms XAML schema in a .xsd file placed in the proper folder of visual studio at the installation time. I guess the NuGet package/tasks don't have at the installation time and the access required by the OS(unless you run Visual Studio as Admin and hardcoded paths into NuGet package install tasks, which is not good idea) to do it.

I've throw this same question to Xamarin team and they replied that the Intellisense is yet to come in following updates and the designer in a future(don't know how soon, even for the alpha/beta channels of update).

Hope it helps...

I've just read a tweet about a Xamarin.Forms Designer being announced at Xamarin Evolve 2016 conference

In the mean time you could use the Windows Phone designer and a converter to spit out Xamarin.Forms markup, see: http://www.gui-innovations.com/Blog%20Posts/windows-phones-forms-to-xamarin-forms.html

That tool is also mentioned at together with other related tools at: https://github.com/MvvmCross/MvvmCross-Forms/wiki/XAML-Tools-for-Xamarin

在此输入图像描述

I created two videos that cover how you can use Xamarin Studio's new XAML Previewer:

Intro:

Using Design Data:

Design Data with ViewModelLocator:

An example of the code involved:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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