Xamarin表示UWP,我如何使用Iconize和Images

时间:2017-05-04 21:05:32

标签: xamarin uwp xamarin.forms xamarin.uwp

我有一个Xamarin PCL Android / iOS / UWP项目。我使用Iconize FontAwsome图标的应用程序。问题是UWP剂量显示任何图标,但Android确实

像这样:

enter image description here 我的表格:

    <?xml version="1.0" encoding="utf-8" ?>
<controls:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
                   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   xmlns:controls="clr-namespace:Volaapp.Controls;assembly:Volaapp"
                   xmlns:converters="clr-namespace:Volaapp.Converters;assembly:Volaapp"
                   xmlns:icons="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize"
                   xmlns:xlabs="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
                   x:Class="Volaapp.Pages.CreateTodoPage"
                   BackgroundColor="{StaticResource GrayColor}"
                   Title="Lisa uus võlg">
  <ScrollView BackgroundColor="{StaticResource WhiteColor}">
    <StackLayout Margin="10"
                 BackgroundColor="{StaticResource WhiteColor}">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="65"/>
          <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition/>
          <RowDefinition Height="65"/>
          <RowDefinition Height="65"/>
          <RowDefinition Height="65"/>
          <RowDefinition Height="65"/>
          <RowDefinition/>
        </Grid.RowDefinitions>

        <!--Nimi ja Summa-->
        <StackLayout Grid.Column="0" Grid.Row="0"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     VerticalOptions="FillAndExpand"
                     HorizontalOptions="FillAndExpand">
          <icons:IconImage VerticalOptions="CenterAndExpand"
                 HorizontalOptions="Center"
                 Icon="fa-gg"
                 IconColor="{StaticResource MetroBlackColor}"
                 HeightRequest="30"/>
        </StackLayout>
        <StackLayout Grid.Column="1" Grid.Row="0"
                     Orientation="Vertical"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
          <StackLayout Orientation="Vertical"
                       BackgroundColor="{StaticResource WhiteColor}"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       Margin="0,1,1,1">
            <Entry Text="{Binding Title}"
                   Placeholder="Sisesta pealkiri"
                   VerticalOptions="EndAndExpand"
                   Keyboard="Text"
                   Margin="15,0,15,2"/>
            <Entry 
                   VerticalOptions="EndAndExpand"
                   Placeholder="Sisesta Summa!"
                   Text="{Binding Loan}"
                   Keyboard="Numeric"
                   Margin="15,2,15,10"
          />
          </StackLayout>
        </StackLayout>

        <!--Inimesed-->
        <StackLayout Grid.Column="0" Grid.Row="1"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     VerticalOptions="FillAndExpand"
                     HorizontalOptions="FillAndExpand">
          <icons:IconImage VerticalOptions="CenterAndExpand"
                 HorizontalOptions="Center"
                 Icon="fa-user"
                 IconColor="{StaticResource MetroBlackColor}"
                 HeightRequest="30"/>
        </StackLayout>
        <StackLayout Grid.Column="1" Grid.Row="1"
                     Orientation="Vertical"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
          <StackLayout Orientation="Vertical"
                       BackgroundColor="{StaticResource WhiteColor}"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       Margin="0,1,1,1">
            <controls:BindablePicker Margin="20,5"
                                     ItemsSource="{Binding Tags}"
                                     SelectedItem="{Binding SelectedTag, Mode=TwoWay}"
                                     DisplayMemberPath="Title"
                                     Title="Vali inimene"
                                     VerticalOptions="EndAndExpand"/>
          </StackLayout>
        </StackLayout>

        <!--Rahatäht-->
        <StackLayout Grid.Column="0" Grid.Row="2"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     VerticalOptions="FillAndExpand"
                     HorizontalOptions="FillAndExpand">
          <icons:IconImage VerticalOptions="CenterAndExpand"
                 HorizontalOptions="Center"
                 Icon="fa-money"
                 IconColor="{StaticResource MetroBlackColor}"
                 HeightRequest="30"/>
        </StackLayout>
        <StackLayout Grid.Column="1" Grid.Row="2"
                     Orientation="Vertical"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
          <StackLayout Orientation="Vertical"
                       BackgroundColor="{StaticResource WhiteColor}"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       Margin="0,1,1,1">
            <controls:BindablePicker Margin="20,5"
                                     ItemsSource="{Binding CurrencyList}"
                                     SelectedItem="{Binding Currency, Mode=TwoWay}"
                                     Title="Vali Rahatäht"
                                     VerticalOptions="EndAndExpand"/>
          </StackLayout>
        </StackLayout>

        <!--Due date-->
        <StackLayout Grid.Column="0" Grid.Row="3"
                     Orientation="Vertical"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     VerticalOptions="FillAndExpand"
                     HorizontalOptions="FillAndExpand">

          <xlabs:ImageButton Image="_duedate.png"
                   ImageHeightRequest="35"
                   ImageWidthRequest="35"
                   BackgroundColor="{StaticResource MetroWhiteColor}"
                   VerticalOptions="CenterAndExpand"
                   HorizontalOptions="Center"
                   BorderRadius="0"
                   Command="{Binding SelectDueDateCommand}"/>
        </StackLayout>
        <StackLayout Grid.Column="1" Grid.Row="3"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
          <StackLayout BackgroundColor="{StaticResource WhiteColor}"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       Margin="0,1,1,1">
            <Label Text="{Binding DueTime, StringFormat='Kuupäev  {0:dd.MM.yyyy HH:mm}'}"
                   FontSize="17"
                   Margin="25,0"
                   TextColor="{StaticResource BlackColor}"
                   VerticalTextAlignment="Start"
                   VerticalOptions="CenterAndExpand"
                   HorizontalOptions="StartAndExpand">
            </Label>
          </StackLayout>
        </StackLayout>

        <!--Meeldetuletus-->
        <StackLayout Grid.Column="0" Grid.Row="4"
                     Orientation="Vertical"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     VerticalOptions="FillAndExpand"
                     HorizontalOptions="FillAndExpand">
          <Image HeightRequest="35"
                 WidthRequest="35"
                 Source="{Binding ReminderIcon}"
                 VerticalOptions="CenterAndExpand"
                 HorizontalOptions="CenterAndExpand">
          </Image>


        </StackLayout>
        <StackLayout Grid.Column="1" Grid.Row="4"
                     BackgroundColor="{StaticResource MetroWhiteColor}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
          <StackLayout BackgroundColor="{StaticResource WhiteColor}"
                       Orientation="Horizontal"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       Margin="0,1,1,1">
            <Label Text="Meeldetuletus"
                   FontSize="17"
                   Margin="25,0,0,0"
                   TextColor="{StaticResource BlackColor}"
                   VerticalTextAlignment="Start"
                   VerticalOptions="CenterAndExpand"
                   HorizontalOptions="Start"/>
            <Switch IsToggled="{Binding EnableReminder, Mode=TwoWay}"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Start"
                    Margin="20,0"/>
          </StackLayout>
        </StackLayout>

        <!--Button-->
        <StackLayout Grid.Column="1" Grid.Row="5"
                   Orientation="Horizontal" Margin="0,30"
                   HorizontalOptions="EndAndExpand"
                   VerticalOptions="CenterAndExpand">
          <xlabs:ImageButton
                             BackgroundColor="{StaticResource MetroWhiteColor}"
                             Text="SAVE" FontSize="12"
                             IsEnabled="{Binding IsValid}"
                             HorizontalOptions="StartAndExpand"
                             HeightRequest="40"
                             WidthRequest="100"
                             BorderRadius="0"
                             Command="{Binding SaveCommand}"/>
          <xlabs:ImageButton
                           BackgroundColor="{StaticResource MetroWhiteColor}"
                           Text="CANCEL"
                           HorizontalOptions="StartAndExpand"
                           BorderRadius="0"
                           HeightRequest="40"
                           WidthRequest="100"
                           FontSize="12"
                           Command="{Binding CancelCommand}"/>
        </StackLayout>
      </Grid>
    </StackLayout>
  </ScrollView>
</controls:BasePage>

我是否错过了金块或UWP剂量支持iconize?

UWP中安装的用于iconize的块:

  • Xam.Plugin.Iconize.FontAwsome
  • Xam.Plugin.Iconize
  • Xam.FormsPlugin.Iconize
  • FontAwsome.UWP

1 个答案:

答案 0 :(得分:1)

这是已知但未确认的问题,似乎在当前版本中没有修复。 GitHub Issue #13。我也遇到了同样的问题。

解决方法是:

  • 在根目录中创建一个文件夹Plugin.Iconize.Material.UWP \ Assets \ Fonts \ 你的项目。
  • 将fontawesome.ttf复制到新目录并进行设置 如果输出更新则复制。