共用方式為


BarcodeScannerPreviewActivatedEventArgs.ConnectionId 屬性

定義

取得用來比對服務連線的連線識別碼。

public:
 property Platform::String ^ ConnectionId { Platform::String ^ get(); };
winrt::hstring ConnectionId();
public string ConnectionId { get; }
var string = barcodeScannerPreviewActivatedEventArgs.connectionId;
Public ReadOnly Property ConnectionId As String

屬性值

String

Platform::String

winrt::hstring

連線識別碼。

實作

範例

此範例會從啟動的引數取得 Connction ID,然後使用它來啟動影片預覽頁面。

protected override async void OnActivated(IActivatedEventArgs args)
{
    base.OnActivated(args);

    if (args.Kind == ActivationKind.BarcodeScannerProvider)
    {
        ... // Create and activate root frame. 

        var eventArgs = args as BarcodeScannerPreviewActivatedEventArgs;
        string connectionId = eventArgs.ConnectionId;

        BarcodeScannerProviderConnection connection = _taskList.GetConnection(connectionId);
        if (connection != null)
        {
            var page = rootFrame.Content as MainPage;
            if (page != null)
            {
                await page.StartVideoPreview(connection);
            }
        }
    }
}


適用於