次の方法で共有


Device.OnPlatform メソッド

定義

オーバーロード

OnPlatform(Action, Action, Action, Action)
古い.

Xamarin.Forms が動作している TargetPlatform に応じて、異なるアクションを実行します。

OnPlatform<T>(T, T, T)
古い.

Xamarin.Forms が動作している TargetPlatform に応じて、異なる値を返します。

OnPlatform(Action, Action, Action, Action)

注意事項

OnPlatform is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.

Xamarin.Forms が動作している TargetPlatform に応じて、異なるアクションを実行します。

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Obsolete("OnPlatform is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.")]
public static void OnPlatform(Action iOS = default, Action Android = default, Action WinPhone = default, Action Default = default);
static member OnPlatform : Action * Action * Action * Action -> unit

パラメーター

iOS
System.Action

(省略可能) iOS で実行するアクション。

Android
System.Action

(省略可能) Android で実行するアクション。

WinPhone
System.Action

(省略可能) WinPhone で実行するアクション。

Default
System.Action

(省略可能) 現在の OS にアクションが指定されていない場合に実行するアクション。

属性
System.ComponentModel.EditorBrowsableAttribute System.ObsoleteAttribute

注釈

この例では、1 つの OS で Label のフォントを変更する方法を示します。

Device.OnPlatform (iOS: () => label.Font = Font.OfSize ("HelveticaNeue-UltraLight", NamedSize.Large));

適用対象

OnPlatform<T>(T, T, T)

注意事項

OnPlatform<> (generic) is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.

Xamarin.Forms が動作している TargetPlatform に応じて、異なる値を返します。

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Obsolete("OnPlatform<> (generic) is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.")]
public static T OnPlatform<T>(T iOS, T Android, T WinPhone);
static member OnPlatform : 'T * 'T * 'T -> 'T

型パラメーター

T

返される値の型。

パラメーター

iOS
T

iOS の値。

Android
T

Android の値。

WinPhone
T

WinPhone の値。

戻り値

T

現在の OS の値。

属性
System.ComponentModel.EditorBrowsableAttribute System.ObsoleteAttribute

注釈

この例では、異なる OS 上のボタンに異なる高さを使用する方法を示します。

button.HeightRequest = Device.OnPlatform (20,30,30);

適用対象