Package.IsOptional Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates whether the package is optional.
public:
property bool IsOptional { bool get(); };
bool IsOptional();
public bool IsOptional { get; }
var boolean = package.isOptional;
Public ReadOnly Property IsOptional As Boolean
Property Value
Boolean
bool
Returns true if the package is optional; false otherwise.
Windows requirements
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
Examples
// Get the main app package
Package currentPackage = Package.Current;
// Get a list of dependencies for the main package. This includes all resource packages, framework packages, and optional packages.
IReadOnlyList<Package> dependencies = currentPackage.Dependencies;
foreach (Package package in dependencies.Where(_ => _.IsOptional))
{
// Iterate through a list of the optional packages
}
Remarks
Optional packages are dependent on another package that must be installed first. For example a map application may have optional geographic area packages.