簡體   English   中英

是否可以使用Xaml設計器或智能感知與Xamarin.Forms?

[英]Is it possible to use a Xaml designer or intellisense with 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設計器?

Xamarin.Forms沒有圖形設計器(但是?)。 intellisense有兩部分:

  • 引用標記為x XAML元素:代碼名稱后面均Xamarin.Studio和VisualStudio的作品
  • Xaml完成元素和屬性在Xamarin.Studio中工作,並且很快就會支持完成屬性值。 不幸的是,VisualStudio中的Xaml智能感知現在不起作用。 但問題是眾所周知的,並且研​​究了解決方案。

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

在此輸入圖像描述

Intellisense已經以第一種形式發布,更多信息請點擊此處:

Mobile Essentials:面向移動開發人員的生產力工具

Xamarin Studio 6.1+包含一個XAML預覽器:

在此輸入圖像描述

它並不完美,但是作為“預覽”版本在iOS和Android上以不同的分辨率呈現您的XAML,包括不同的方向。

需要注冊的視頻: https//brax.tv/lesson/xamarin-forms-hello-xaml-previewer/

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

(此帖發布時的官方Evolve視頻尚未在線)

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

一家第三方公司正在開發一款名為UI Sleuth的Xamarin.Forms Designer。

他們仍處於秘密模式,但已發布了幾個演示視頻:

我建議在推特上關注首席架構師 這是他們發布最新的UI Sleuth更新的地方!

在VS上實現Intellisense所需的只是在安裝時將.xsd文件中的Xamarin.Forms XAML模式放在visual studio的正確文件夾中。 我想NuGet包/任務在安裝時沒有操作系統所需的訪問權限(除非你將Visual Studio作為Admin運行並且硬編碼路徑運行到NuGet包安裝任務中,這不是一個好主意)。

我已經向Xamarin團隊提出了同樣的問題,他們回答說Intellisense還有未來的更新和未來的設計師(不知道多久,即使是alpha / beta頻道的更新)。

希望能幫助到你...

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

在此輸入圖像描述

我創建了兩個視頻,介紹了如何使用Xamarin Studio的新XAML預覽器:

介紹:

使用設計數據:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM