File​Activated​Event​Args File​Activated​Event​Args File​Activated​Event​Args Class

Definition

Provides data when an app is activated because it is the app associated with a file.

JavaScript This type appears as WebUIFileActivatedEventArgs.

public : sealed class FileActivatedEventArgs : IActivatedEventArgs, IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProviderpublic sealed class FileActivatedEventArgs : IActivatedEventArgs, IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProviderPublic NotInheritable Class FileActivatedEventArgs Implements IActivatedEventArgs, IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IFileActivatedEventArgs, IFileActivatedEventArgsWithCallerPackageFamilyName, IFileActivatedEventArgsWithNeighboringFiles, IViewSwitcherProvider
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The OnFileActivated event handler on the Application object receives all file activation events.

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^ args)
{
       // TODO: Handle file activation

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

Remarks

This object is accessed when you implement an event handler to respond to Activated events when ActivationKind is File.

Windows Store app using C++, C#, or Visual Basic typically implement activation points by overriding methods of the Application object. The default template app.xaml code-behind files always include an override for OnLaunched, but defining overrides for other activation points such as OnFileActivated is up to your app code.

All Application overrides involved in an activation scenario should call Window.Activate in their implementations.

Note that when your app is activated for the file contract you must access the data using the StorageFile objects passed to your app through the Files property. You should not attempt to access the path of the file since your app may not have permission to the file’s location.

Properties

CallerPackageFamilyName CallerPackageFamilyName CallerPackageFamilyName

The package family name of the app that launched your app.

public : PlatForm::String CallerPackageFamilyName { get; }public string CallerPackageFamilyName { get; }Public ReadOnly Property CallerPackageFamilyName As string
Value
PlatForm::String string string

The caller's package family name.

Attributes

Remarks

If the caller is a non-packaged app (such as a Win32 app), CallerPackageFamilyName will be empty, that is "".

CurrentlyShownApplicationViewId CurrentlyShownApplicationViewId CurrentlyShownApplicationViewId

Gets the identifier for the currently shown app view.

public : int CurrentlyShownApplicationViewId { get; }public int CurrentlyShownApplicationViewId { get; }Public ReadOnly Property CurrentlyShownApplicationViewId As int
Value
int int int

The identifier for the currently shown app view.

Attributes

Files Files Files

Gets the files for which the app was activated.

public : IVectorView<IStorageItem> Files { get; }public IReadOnlyList<IStorageItem> Files { get; }Public ReadOnly Property Files As IReadOnlyList<IStorageItem>
Value
IVectorView<IStorageItem> IReadOnlyList<IStorageItem> IReadOnlyList<IStorageItem>

The StorageFile objects representing the files being passed to the app.

Attributes
See Also

Kind Kind Kind

Gets the activation type.

public : ActivationKind Kind { get; }public ActivationKind Kind { get; }Public ReadOnly Property Kind As ActivationKind
Value
ActivationKind ActivationKind ActivationKind

One of the enumeration values.

Attributes
See Also

NeighboringFilesQuery NeighboringFilesQuery NeighboringFilesQuery

Gets the neighboring files of the files for which the app was activated.

public : StorageFileQueryResult NeighboringFilesQuery { get; }public StorageFileQueryResult NeighboringFilesQuery { get; }Public ReadOnly Property NeighboringFilesQuery As StorageFileQueryResult
Value
StorageFileQueryResult StorageFileQueryResult StorageFileQueryResult

The StorageFile objects that represent the neighboring files of the files being passed to the app.

Attributes

Remarks

Apps that activate to handle file associations get an object that represents the invoked file only. This can be a problem for media gallery apps in which users expect to navigate to neighboring files. Use the NeighboringFilesQuery property to get the collection of the files in the surrounding view, which is the collection that the invoked file was selected from.

Your apps need to declare a library capability to get items of the corresponding type. To get pictures in the NeighboringFilesQuery, you need the Pictures library capability, and to get music files, you need the Music library capability.

The NeighboringFilesQuery property is available only when a single file is invoked. If the size of the Files collection is more than 1, the value of NeighboringFilesQuery is null. Also, the query is not always available for all invocations, so you can use it only if present.

PreviousExecutionState PreviousExecutionState PreviousExecutionState

Gets the execution state of the app before it was activated.

public : ApplicationExecutionState PreviousExecutionState { get; }public ApplicationExecutionState PreviousExecutionState { get; }Public ReadOnly Property PreviousExecutionState As ApplicationExecutionState
Attributes
See Also

SplashScreen SplashScreen SplashScreen

Gets the splash screen object that provides information about the transition from the splash screen to the activated app.

public : SplashScreen SplashScreen { get; }public SplashScreen SplashScreen { get; }Public ReadOnly Property SplashScreen As SplashScreen
Value
SplashScreen SplashScreen SplashScreen

The object that provides splash screen information.

Attributes
See Also

User User User

Gets the user that the app was activated for.

public : User User { get; }public User User { get; }Public ReadOnly Property User As User
Value
User User User

The user that the app was activated for.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

This property returns the logged-in user on platforms that only support single-user sessions. For platforms that support multiple users in a session (such as Xbox) this property returns the logged-in user that the app was activated for.

This property returns null when a multi-user application is activated with no specific user context.

Multi-user apps can use this property to allow or restrict app behavior. For example, you might restrict access to content or features based on the user’s credentials.

Verb Verb Verb

Gets the action associated with the activated file.

public : PlatForm::String Verb { get; }public string Verb { get; }Public ReadOnly Property Verb As string
Value
PlatForm::String string string

The action.

Attributes
See Also

ViewSwitcher ViewSwitcher ViewSwitcher

Provides the object that allows you to set the view for the application.

public : ActivationViewSwitcher ViewSwitcher { get; }public ActivationViewSwitcher ViewSwitcher { get; }Public ReadOnly Property ViewSwitcher As ActivationViewSwitcher
Value
ActivationViewSwitcher ActivationViewSwitcher ActivationViewSwitcher

Use the ActivationViewSwitcher to show or switch the view in response to the activation. The value will be null in hosted scenarios such as Share and File Picker activations.

Attributes

See Also