按钮图标不显示 xamarins 窗体 xaml



我是xaml的新手,遇到了一个问题。我正试图在xamarin.forms中的文本旁边创建一个带有图标的按钮。但当我试图显示它时,我的应用程序上什么都没有。添加png图标。图像位于Ressources->drawable文件夹中。这是xaml代码。

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="epicture.MainPage">
<StackLayout>
<Button Text="Log in" ImageSource="login.png" Clicked="Button_Clicked" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" BackgroundColor="#00c851" TextColor="White"></Button>
<WebView Navigating="WebView_Navigating"></WebView>
</StackLayout>
</ContentPage>

我也面临同样的问题ImageButton并没有文本属性。正因为如此,我创建了带有文本属性的自定义ImageButton控件,你可以参考它,这可能会对你有所帮助。

https://xamarincodingtutorial.blogspot.com/2019/05/step-to-create-imagebutton-with-text.html

最新更新