WebView 類
定義
程式集:Xamarin.Forms.Core.dll
呈現 HTML 內容的 View。A View that presents HTML content.
本文內容
[Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._WebViewRenderer))]
public class WebView : Xamarin.Forms.View, Xamarin.Forms.IElementConfiguration, Xamarin.Forms.IWebViewController
type WebView = class
inherit View
interface IWebViewController
interface IViewController
interface IVisualElementController
interface IElementController
interface IElementConfiguration
註解
下面的範例演示了一個基本的用法。The following example shows a basic use.
using System;
using Xamarin.Forms;
namespace FormsGallery
{
class WebViewDemoPage : ContentPage
{
public WebViewDemoPage()
{
Label header = new Label
{
Text = "WebView",
FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
WebView webView = new WebView
{
Source = new UrlWebViewSource
{
Url = "https://blog.xamarin.com/",
},
VerticalOptions = LayoutOptions.FillAndExpand
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
webView
}
};
}
}
}

建構函式
新建具有預設值的 WebView 元素。Creates a new WebView element with default values.
欄位
屬性
取得或設定任何轉換的中心點的 X 部分,相對於元素的邊界。Gets or sets the X component of the center point for any transform, relative to the bounds of the element. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定任何轉換的中心點的 Y 部分,相對於元素的邊界。Gets or sets the Y component of the center point for any transform, relative to the bounds of the element. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定允許自動化框架搜尋此元素並與其互動的值。Gets or sets a value that allows the automation framework to find and interact with this element.
(繼承自 Element)
取得或設定將填充 VisualElement 背景的顏色。Gets or sets the color which will fill the background of a VisualElement. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
取得與此元素關聯的 Behavior 串列。Gets the list of Behaviors associated to this element. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定物件,該物件包含將被屬於此 BindableObject 的繫結屬性設定為目標的屬性。Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.
(繼承自 BindableObject)
取得元素的邊界。Gets the bounds of the element.
(繼承自 VisualElement)
取得一個值,該值指示使用者是否可導覽到上一頁。Gets a value that indicates whether the user can navigate to previous pages.
取得一個值,該值指示使用者是否可向前導覽。Gets a value that indicates whether the user can navigate forward.
取得或設定用於標識語意相似元素集合的值。Gets or sets a value used to identify a collection of semantically similar elements.
(繼承自 Element)
設定後,這將作為 Cookie 的同步。When set this will act as a sync for cookies.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
應用於此項的效果串列。A list of the effects that are applied to this item.
(繼承自 Element)
取得或設定佈局流方向。Gets or sets the layout flow direction.
(繼承自 VisualElement)
取得檢視表的手勢控制器。Gets the gesture controller for the view.
(繼承自 View)
與此檢視表關聯的手勢識別器的集合。The collection of gesture recognizers associated with this view.
(繼承自 View)
取得此元素的當前呈現高度。Gets the current rendered height of this element. 這是一種唯讀可繫結屬性。This is a read-only bindable property.
(繼承自 VisualElement)
取得或設定此元素的所需高度替代。Gets or sets the desired height override of this element.
(繼承自 VisualElement)
取得或設定 LayoutOptions,它定義元素在佈局週期中的佈局方式。Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. 這是一種可繫結屬性。This is a bindable property.
(繼承自 View)
取得可用於透過執行應用程式唯一地標識元素的值。Gets a value that can be used to uniquely identify an element through the run of an application.
(繼承自 Element)
取得或設定一個值,該值指示此元素是否應涉及使用者互動週期。Gets or sets a value indicating whether this element should be involved in the user interaction cycle. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定一個值,該值指示是否在使用者介面中啟用此元素。Gets or sets a value indicating whether this element is enabled in the user interface. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得一個值,該值指示當前是否聚焦此元素。Gets a value indicating whether this element is focused currently. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
取得或設定指明此元素是否包含在索引標籤導覽中的值。Gets or sets a value that indicates whether this element is included in tab navigation. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定一個值,該值確定此元素是否應屬於視覺化樹的一部分。Gets or sets a value that determines whether this elements should be part of the visual tree or not. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
取得或設定檢視表的邊距。Gets or sets the margin for the view.
(繼承自 View)
取得或設定一個值,該值將替代元素在佈局期間請求的最小高度。Gets or sets a value which overrides the minimum height the element will request during layout.
(繼承自 VisualElement)
取得或設定一個值,該值將替代元素在佈局期間請求的最小寬度。Gets or sets a value which overrides the minimum width the element will request during layout.
(繼承自 VisualElement)
取得或設定呈現元素時應用於元素的不透明度值。Gets or sets the opacity value applied to the element when it is rendered. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定元素的父元素。Gets or sets the parent element of the element.
(繼承自 Element)
已過時。
取得作為 VisualElement 的此元素的最近的上級元素。Gets the element which is the closest ancestor of this element that is a VisualElement.
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
取得或設定本地資源字典。Gets or sets the local resource dictionary.
(繼承自 VisualElement)
取得或設定呈現元素時圍繞 Z 軸(仿射旋轉)的旋轉角度(以度為單位)。Gets or sets the rotation (in degrees) about the Z-axis (affine rotation) when the element is rendered.
(繼承自 VisualElement)
取得或設定呈現元素時圍繞 X 軸(透視旋轉)的旋轉角度(以度為單位)。Gets or sets the rotation (in degrees) about the X-axis (perspective rotation) when the element is rendered.
(繼承自 VisualElement)
取得或設定呈現元素時圍繞 Y 軸(透視旋轉)的旋轉角度(以度為單位)。Gets or sets the rotation (in degrees) about the Y-axis (perspective rotation) when the element is rendered.
(繼承自 VisualElement)
取得或設定應用於元素的比例因子。Gets or sets the scale factor applied to the element.
(繼承自 VisualElement)
取得或設定要應用於 X 方向的縮放值。Gets or sets a scale value to apply to the X direction.
(繼承自 VisualElement)
取得或設定要應用於 Y 方向的縮放值。Gets or sets a scale value to apply to the Y direction.
(繼承自 VisualElement)
Gets or sets the WebViewSource object that represents the location that this WebView object displays.
取得或設定用於唯一地標識元素的使用者定義的值。Gets or sets a user defined value to uniquely identify the element.
(繼承自 Element)
取得或設定元素的 X 轉換增量。Gets or sets the X translation delta of the element.
(繼承自 VisualElement)
取得或設定元素的 Y 轉換增量。Gets or sets the Y translation delta of the element.
(繼承自 VisualElement)
取得與此元素關聯的 Trigger 串列。Gets the list of Trigger associated to this element. 這是一種可繫結屬性。This is a bindable property.
(繼承自 VisualElement)
取得或設定 LayoutOptions,它定義元素在佈局週期中的佈局方式。Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. 這是一種可繫結屬性。This is a bindable property.
(繼承自 View)
取得此元素的當前呈現寬度。Gets the current rendered width of this element. 這是一種唯讀可繫結屬性。This is a read-only bindable property.
(繼承自 VisualElement)
取得或設定此元素的所需寬度替代。Gets or sets the desired width override of this element.
(繼承自 VisualElement)
取得此元素的當前 X 位置。Gets the current X position of this element. 這是一種唯讀可繫結屬性。This is a read-only bindable property.
(繼承自 VisualElement)
取得此元素的當前 Y 位置。Gets the current Y position of this element. 這是一種唯讀可繫結屬性。This is a read-only bindable property.
(繼承自 VisualElement)
方法
表示開始對元素屬性進行批更改。Signals the start of a batch of changes to the elements properties.
(繼承自 VisualElement)
表示元素命令批處理結束,且現在應提交命令。Signals the end of a batch of commands to the element and that those commands should now be committed.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
清除由 SetValue 為 property 設定的任何值。Clears any value set by SetValue for property.
(繼承自 BindableObject)
清除由 SetValue 為 propertyKey 標識的屬性設定的任何值。Clears any value set by SetValue for the property that is identified by propertyKey.
(繼承自 BindableObject)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
計算由 script 指定的腳本。Evaluates the script that is specified by script.
在支援 JavaScript 計算的平台上,計算 script。On platforms that support JavaScript evaluation, evaluates script.
回傳具有指定名稱的元素。Returns the element that has the specified name.
(繼承自 Element)
嘗試將焦點設定到此元素上。Attemps to set focus to this element.
(繼承自 VisualElement)
回傳在指定的 point 下可見的子元素。Returns the child elements that are visually beneath the specified point.
(繼承自 View)
已過時。
Returns the SizeRequest of the element. 呼叫此方法開始佈局迴圈的測量過程。Calling this method begins the measure pass of a layout cycle.
(繼承自 VisualElement)
回傳 BindableProperty 中包含的值。Returns the value that is contained in the BindableProperty.
(繼承自 BindableObject)
已過時。
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 BindableObject)
已過時。
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 BindableObject)
導覽到上一頁。Navigates to the previous page.
導覽到訪問頁串列中的下一頁。Navigates to the next page in the list of visited pages.
呼叫此方法以使此 VisualElement 的佈局無效。Method that is called to invalidate the layout of this VisualElement.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
如果目標屬性存在並且已設定,則回傳 true。Returns true if the target property exists and has been set.
(繼承自 BindableObject)
在佈局迴圈中更新元素的邊界。Updates the bounds of the element during the layout cycle.
(繼承自 VisualElement)
回傳在裝置上顯示可視元素所需的最小大小。Returns the minimum size that a visual element needs in order to be displayed on the device.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
回傳此 WebView 的特定於平台的例項,可對其呼叫特定於平台的方法。Returns the platform-specific instance of this WebView, on which a platform-specific method may be called.
繫結上下文更改時呼叫的方法。Method that is called when the binding context is changed.
應用程式開發者可以重寫此方法以在新增子級時進行回應。Application developers can override this method to respond when a child is added.
(繼承自 VisualElement)
已過時。
應用程式開發者可以重寫此方法以在刪除子級時進行回應。Application developers can override this method to respond when a child is removed.
(繼承自 VisualElement)
Invoked whenever the ChildrenReordered event is about to be emitted. 實現此方法可為此事件新增類處理。Implement this method to add class handling for this event.
(繼承自 VisualElement)
進行佈局測量時呼叫的方法。Method that is called when a layout measurement happens.
(繼承自 VisualElement)
更改 Source 時呼叫的方法。Method that is called when Source is changed.
從子類別呼叫此方法以通知屬性將要發生更改。Call this method from a child class to notify that a change is going to happen on a property.
(繼承自 BindableObject)
在佈局迴圈過程中設定元素的大小時呼叫此方法。This method is called when the size of the element is set during a layout cycle. 在發出 SizeChanged 事件之前直接呼叫此方法。This method is called directly before the SizeChanged event is emitted. 實現此方法可為此事件新增類處理。Implement this method to add class handling for this event.
(繼承自 VisualElement)
已過時。
此方法在對佈局迴圈的測量過程中呼叫,以取得需要的元素大小。This method is called during the measure pass of a layout cycle to get the desired size of an element.
(繼承自 VisualElement)
更改由 sender 引數指定的檢視表源時所呼叫的方法。Method that is called when the view source that is specified by the sender parameter is changed.
刪除先前設定的繫結。Removes a previously set binding.
(繼承自 BindableObject)
移除先前設定的動態資源Removes a previously set dynamic resource
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
將此元素的 BindableProperty 屬性設定為透過 DynamicResource 使用提供的鍵來更新。Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key.
(繼承自 Element)
設定指定屬性的值。Sets the value of the specified property.
(繼承自 BindableObject)
設定 propertyKey 的值。Sets the value of the propertyKey.
(繼承自 BindableObject)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 BindableObject)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
在佈局迴圈過程中呼叫 SizeAllocated 以指示子樹佈局的開始。SizeAllocated is called during a layout cycle to signal the start of a sub-tree layout.
(繼承自 VisualElement)
不應用所有以前設定的繫結。Unapplies all previously set bindings.
(繼承自 BindableObject)
取消設定此元素的焦點。Unsets focus to this element.
(繼承自 VisualElement)
事件
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
每當將子元素新增到元素時就會發生。Occurs whenever a child element is added to the element.
(繼承自 Element)
每當從元素中刪除子元素時就會發生。Occurs whenever a child element is removed from the element.
(繼承自 Element)
重新排序 VisualElement 的子級時發生。Occurs when the Children of a VisualElement have been re-ordered.
(繼承自 VisualElement)
每當將子元素新增到元素子樹時就會發生。Occurs whenever a child element is added to the elements subtree.
(繼承自 Element)
每當從元素子樹中刪除子元素時就會發生。Occurs whenever a child element is removed from the elements subtree.
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 VisualElement)
元素接收焦點時發生。Occurs when the element receives focus.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
可視元素的佈局無效時引發的事件。Event that is raised when the layout of a visual element is invalidated.
(繼承自 VisualElement)
完成導覽後引發的事件。Event that is raised after navigation completes.
導覽開始時引發的事件。Event that is raised when navigation starts.
在屬性已更改時引發。Raised when a property has changed.
(繼承自 BindableObject)
在屬性將要更改時引發。Raised when a property is about to change.
(繼承自 BindableObject)
當此元素上的 Width 或 Height 屬性的值發生更改時發生。Occurs when either the Width or the Height properties change value on this element.
(繼承自 VisualElement)
當元素遺失焦點時發生。Occurs when the element loses focus.
(繼承自 VisualElement)
顯式介面實現
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 Element)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
(繼承自 View)
取得平台上元素的有效可視流方向,考慮區域設定和邏輯流設定。Gets the effective visual flow direction for the element on the platform, taking into account the locale and logical flow settings.
(繼承自 VisualElement)
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
供 Xamarin.Forms 平台內部使用。For internal use by the Xamarin.Forms platform.
擴展方法
回傳一個布林值,該值指示 handle 指定的影片是否正在執行。Returns a Boolean value that indicates whether or not the animation that is specified by handle is running.
回傳包含 element 的作用域中名稱為 name 的型別 T 的例項。Returns the instance of type T that has name name in the scope that includes element.
回傳一個任務,它執行 opacity、length 和 easing 引數描述的淡化。Returns a task that performs the fade that is described by the opacity, length, and easing parameters.
回傳一個任務,它將 view 指定的 VisualElement 的邊界簡化為 bounds 引數指定的矩形。Returns a task that eases the bounds of the VisualElement that is specified by the view to the rectangle that is specified by the bounds parameter.
從當前旋轉將 view 指定的 VisualElement 旋轉為 drotation。Rotates the VisualElement that is specified by view from its current rotation by drotation.
回傳一個任務,它將 view 指定的 VisualElement 從其當前比例縮放到 dscale。Returns a task that scales the VisualElement that is specified by view from its current scale to dscale.
回傳一個任務,它執行 rotation、length 和 easing 引數描述的旋轉。Returns a task that performs the rotation that is described by the rotation, length, and easing parameters.
回傳將 Y 軸傾斜 opacity 的任務,花費時間 length 並使用 easing。Returns a task that skews the Y axis by opacity, taking time length and using easing.
回傳將 X 軸傾斜 opacity 的任務,花費時間 length 並使用 easing。Returns a task that skews the X axis by opacity, taking time length and using easing.
回傳一個任務,它將 view 指定的 VisualElement 縮放到絕對比例因子 scale。Returns a task that scales the VisualElement that is specified by view to the absolute scale factor scale.
將元素 TranslationX 和 TranslationY 屬性從其當前值影片處理為新的值。Animates an elements TranslationX and TranslationY properties from their current values to the new values. 這可確保輸入佈局與視覺物件佈局處於同一位置。This ensures that the input layout is in the same position as the visual layout.
如果 element 具有與之關聯的一個或多個可視狀態組,則回傳 true。Returns true if element has one or more visual state groups associated with it. 否則回傳 false。Otherwise, returns false.
適用於