Xamarin Forms OnPlatform in Xaml

前端 未结 2 679
慢半拍i
慢半拍i 2021-01-18 14:41

I have the following C# code:

var footer = new StackLayout()
            { BackgroundColor = Device.OnPlatform(Color.FromRgb(225, 240, 251), Color.FromRgb(22         


        
2条回答
  •  孤街浪徒
    2021-01-18 15:07

    Newer version syntax of OnPlatform is slightly different

    In Xaml:

     
                
                    #0000FF
                    #FF0000
                
      
    

    In code:

     switch (Device.RuntimePlatform)
     {
         case "iOS":
         break;
         case "Android":
         break;
         case "UWP":
         break;
         default:
         break;
     }
    

提交回复
热议问题