我需要“更新”以下代码:
namespace Pizzahouse.Pages
{
public class IndexPage : ContentPage
{
public IndexPage()
{
Title = "Index";
var telephone = new Button()
{
Text = "Call",
WidthRequest = 50,
};
telephone.Clicked += (sender, e) => Device.OpenUri(new Uri("tel://123465789"));
Content = new ContentView()
{
Content = new StackLayout()
{
Children = {
new Image
{
Aspect = Aspect.AspectFit,
Source = Device.OnPlatform(
ImageSource.FromFile("PizzaIcon.png"),
ImageSource.FromFile("PizzaIcon.png"),
null)
}, telephone
}
}
};
}
}
}我需要插入一个图像,但是Xamarin.Forms说Device.OnPlataform()方法过时了,它说我应该使用开关(Device.RuntimePlatform)。
这个精确的代码有效,那么你有什么建议?谢谢你的建议。
发布于 2017-08-25 15:04:04
Source = (Device.RuntimePlatform == Device.WinPhone) ? null : ImageSource.FromFile("PizzaIcon.png");https://stackoverflow.com/questions/45884092
复制相似问题