Jay*_*sta 2 xaml xamarin xamarin.forms uwp uwp-xaml
我目前正在Xamarin.Forms UWP中创建一个示例系统.我想知道为什么我的代码调用图像似乎在UWP部分中无法正常工作,而它在Android中工作.我还想将图像设置为背景,将图像设置为按钮.
我如何对其进行编码以使其在两个平台上都能正常运行?
这是我用过的代码:
<?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="XamarinFormsDemo.Views.LoginPage"
BackgroundImage="bg3.jpg"
Title="MainPage">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
<StackLayout VerticalOptions="Center"
Padding="40">
<Image Source="ebmslogo1.png"/>
<StackLayout Padding="0,50,0,0">
<Entry x:Name="txtUserName"
Placeholder="Username"
x:Hint="Username"
BackgroundColor="Black"
TextColor="White"/>
<Entry x:Name="txtPassword"
Placeholder="Password"
IsPassword="true"
BackgroundColor="Black"
TextColor="White"/>
<Button Text="LOG IN"
FontSize="14"
BackgroundColor="Teal"
Clicked="NavigateButton_OnClicked"/>
</StackLayout>
</StackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
我的图片位于.Droid> Resources> drawable
Ada*_*ley 11
对于UWP中的Xamarin Forms,图像必须位于根项目目录中(不在Assets中),并且构建操作设置为Content.
然后,图像将像在Xamarin Forms中的Android和iOS中一样工作.
归档时间: |
|
查看次数: |
4465 次 |
最近记录: |