FileActivatedEventArgs 类

定义

在激活应用时提供数据,因为它是与文件关联的应用。

Javascript 此类型显示为 WebUIFileActivatedEventArgs

public ref class FileActivatedEventArgs sealed : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
public ref class FileActivatedEventArgs sealed : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class FileActivatedEventArgs final : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class FileActivatedEventArgs final : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class FileActivatedEventArgs : IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class FileActivatedEventArgs : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
Public NotInheritable Class FileActivatedEventArgs
Implements IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
Public NotInheritable Class FileActivatedEventArgs
Implements IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
继承
Object IInspectable FileActivatedEventArgs
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

对象 OnFileActivated 上的 Application 事件处理程序接收所有文件激活事件。

protected override void OnFileActivated(FileActivatedEventArgs args)
{
       // TODO: Handle file activation

       // The number of files received is args.Files.Size
       // The first file is args.Files[0].Name
}
Private Sub OnFileActivated(ByVal args As Windows.ApplicationModel.Activation.FileActivatedEventArgs)
      ' TODO: Handle file activation

      ' The number of files received is args.Files.Size
      ' The first file is args.Files(0).Name
End Sub
void App::OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs const& /* args */)
{
    // TODO: Handle file activation.

    // The number of files received is args.Files().Size().
    // The first file is args.Files().GetAt(0).Name().
}
void App::OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs^ args)
{
       // TODO: Handle file activation

       // The number of files received is args->Files->Size
       // The first file is args->Files->GetAt(0)->Name
}

注解

实现事件处理程序以响应Activated文件 时的事件时ActivationKind,将访问此对象。

使用 C++、C# 或 Visual Basic的 UWP 应用通常通过重写对象的方法Application实现激活点。 默认模板 app.xaml 代码隐藏文件始终包含替代,但定义其他激活点的替代 OnLaunched,例如 OnFileActivated 由应用代码决定。

激活方案中涉及的所有 Application 替代都应在其实现中调用 Window.Activate

请注意,当为文件协定激活应用时,必须使用通过StorageFileFiles属性传递给应用的对象访问数据。 不应尝试访问文件的路径,因为应用可能无权访问文件的位置。

版本历史记录

Windows 版本 SDK 版本 增值
1607 14393 User

属性

CallerPackageFamilyName

启动应用的程序包系列名称。

CurrentlyShownApplicationViewId

获取当前显示的应用视图的标识符。

Files

获取激活应用的文件。

Kind

获取激活类型。

NeighboringFilesQuery

获取激活应用的文件的相邻文件。

PreviousExecutionState

获取应用在激活前的执行状态。

SplashScreen

获取初始屏幕对象,该对象提供有关从初始屏幕过渡到激活的应用的信息。

User

获取激活应用的用户。

Verb

获取与激活的文件关联的操作。

ViewSwitcher

提供允许为应用程序设置视图的对象。

适用于

另请参阅