Windows App Runtime
This section provides detailed API reference information for the core components of the Windows App Runtime, enabling you to build modern Windows applications with consistent APIs across different Windows versions.
Represents a Uniform Resource Identifier (URI).
Remarks
The Uri class is fundamental for representing network locations or any resource that can be identified by a Uniform Resource Identifier. It's used extensively in networking, web requests, and other scenarios where identifying resources is necessary.
// Example: Creating a Uri object
var webUri = new Windows.Foundation.Uri("https://docs.microsoft.com");
// Example: Accessing Uri properties
string scheme = webUri.SchemeName; // "https"
string host = webUri.Host; // "docs.microsoft.com"
string absoluteUri = webUri.AbsoluteUri; // "https://docs.microsoft.com/"
Represents a dynamic array (a zero-based, singly indexed collection of objects that can be accessed by index).
Methods
- Append(T value): Adds an item to the end of the list.
- Clear(): Removes all items from the list.
- GetAt(uint index): Retrieves the item at the specified index.
- InsertAt(uint index, T value): Inserts an item at the specified index.
- RemoveAt(uint index): Removes the item at the specified index.
- RemoveAtEnd(): Removes the last item from the list.
- SetAt(uint index, T value): Replaces the item at the specified index with a new item.
Properties
- Size: Gets the number of items in the collection.
// Example: Using IVector to manage a list of strings
var names = new Windows.Foundation.Collections.Vector<string>();
names.Append("Alice");
names.Append("Bob");
names.InsertAt(1, "Charlie"); // names is now ["Alice", "Charlie", "Bob"]
string firstPerson = names.GetAt(0); // "Alice"
uint count = names.Size; // 3
names.RemoveAt(1); // names is now ["Alice", "Bob"]
Provides a channel for logging messages and events within your application.
Constructors
- LoggingChannel(string id): Initializes a new instance of the
LoggingChannelclass with the specified ID. - LoggingChannel(string id, Guid providerGuid): Initializes a new instance of the
LoggingChannelclass with the specified ID and provider GUID.
Methods
- LogMessage(string message): Logs a simple string message.
- LogMessage(string message, LoggingLevel level): Logs a message with a specified logging level.
- LogError(string message): Logs an error message.
- LogWarning(string message): Logs a warning message.
- LogInfo(string message): Logs an informational message.
Remarks
Use LoggingChannel to emit diagnostic information that can be captured and analyzed by logging tools. This is crucial for debugging and understanding application behavior in production environments.
// Example: Using LoggingChannel
var logger = new Windows.Foundation.Diagnostics.LoggingChannel("MyAppComponent");
logger.LogMessage("Application started.");
logger.LogWarning("Configuration file not found, using defaults.");
logger.LogError("Failed to initialize database connection.");
This is a subset of the available APIs. Explore the sidebar to find more categories and specific classes.