2015-10-14 26 views
0

我想在StackLayout中使用一個ImageButton,並試圖設置按鈕的文本設置在圖像下方。但是,文字始終顯示在圖像的右側,而不是下方。這裏是代碼:Xamarin.Forms ImageButton顯示問題

<?xml version="1.0" encoding="utf-8" ?> 
<StackLayout x:Class="MyApp.Portable.Controls.MyNavigationControl" 
      xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms" 
      xmlns:forms="clr-namespace:Xamarin.Forms;assembly=Xamarin.Libraries.PCL" 
      x:Name="MyNavControl" 
      BackgroundColor="White" 
      HorizontalOptions="FillAndExpand" 
      MinimumHeightRequest="75" 
      Orientation="Horizontal"> 
    <StackLayout.Resources> 
    <ResourceDictionary> 
     <Style x:Key="NavButtonStyle" TargetType="Button"> 
     <Setter Property="BackgroundColor" Value="White" /> 
     <Setter Property="TextColor" Value="Gray" /> 
     <Setter Property="FontSize" Value="7" /> 
     </Style> 
    </ResourceDictionary> 
    </StackLayout.Resources> 
    <forms:ImageButton x:Name="GpsButton" 
         Clicked="GpsBUttonClicked" 
         Image="GPS_Icon_Light_Gray_sm.png" 
         MinimumHeightRequest="75" 
         Orientation="ImageOnBottom" 
         Style="{StaticResource NavButtonStyle}" 
         Text="GPS" 
         VerticalOptions="Start" /> 
<StackLayout> 
+0

如果你想在圖片下方的文字,你不應該用「ImageOnTop」方向是什麼? – Jason

+0

這是從測試中遺留下來的......底部或頂部的設置導致文本在右邊 – bbqchickenrobot

+0

是您的按鈕高到足以修復圖像和文本? – Jason

回答

0

如果你還沒有找到它,這裏是你的問題的答案。問題是使用不正確的屬性來設置圖像。 ImageButton.Image屬性將顯示圖像,但它不會遵守任何其他設置屬性,如ImageButton.Orientation。要解決您的問題,您必須設置ImageButton.Source屬性。

更多信息可以在這裏找到:https://github.com/XLabs/Xamarin-Forms-Labs/issues/235