2017-08-25 5 views
2

私は「更新」に次のコードが必要です。私は、画像を挿入する必要がありますが、Xamarin.FormsはDevice.OnPlataform()メソッドは廃止されていることを言います、そしてそれは私がスイッチを使用する必要があることを述べているSwitch(Device.RuntimePlatform)にDevice.OnPlataformを適合させる方法は?

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 
       } 
      } 
     }; 
    } 
} 
} 

を(Device.RuntimePlatform)。

この正確なコードは機能するので、何をお勧めしますか?アドバイスをありがとう。

答えて

2
Source = (Device.RuntimePlatform == Device.WinPhone) ? null : ImageSource.FromFile("PizzaIcon.png"); 
+0

ありがとう、@ジェイソン! – user3000135

関連する問題