我需要"更新"以下代码:
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((方法已经过时,它说我应该使用switch(Device.RuntimePlatform(。
这个确切的代码有效,那么你有什么建议?谢谢建议。
Source = (Device.RuntimePlatform == Device.WinPhone) ? null : ImageSource.FromFile("PizzaIcon.png");