.NET Liverpool - April 2025

Design & Develop Windows Widgets via Generative AI - Peter Bull
Windows Widgets
Windows 11 is Microsoft's latest and most powerful operating system that helps developers, consumers and businesses get things done with features such as snap assist to help organise windows. Windows 11 features an improved Microsoft Store for easy access to movies, TV shows or games along with focus sessions to minimise distractions while you work or play integrating Spotify. Microsoft Copilot to kickstart creativity or act as an intelligent assistant or more with Copilot + PCs enabling local AI functionality in Windows 11 such as Recall available in preview. Widgets are new to Windows 11 and enable quick at-a-glance access to news, weather, share prices and more without having to switch between apps or open a web browser. You can find more about the latest hardware such as Copilot + PCs along with features and functionality in Windows 11 at windows.com.
Widgets in Windows 11 enable quick-and-easy access at-a-glance from a click or swipe of the Widgets Board including built-in and third-party Widgets from the Microsoft Store. Widgets can be customised including based on your interests and preferences or they can be personalised to show the information that is important to you. Widgets can be interactive where you can engage with content directly or content can be dynamic with real-time updates to text and images in Widgets. Widgets allow data visualisation to be done in an easy-to-understand and they can also integrate features such as notifications to inform users. Widgets are designed using Adaptive Cards which can be updated partially with databinding or completely with another Adaptive Card.
Adaptive Cards
Adaptive Cards are platform-agnostic snippets of UI in JSON to create rich interactive templates across platforms or services such as Windows Widgets. Adaptive Cards are used to exchange at-a-glance content supporting elements such as text or images along with layouts such as columns and tables. They can be updated dynamically based on user actions or when any data changes to ensure information is always up-to-date and can be designed with the drag-and-drop designer, by referencing the JSON schema or even by using Generative AI. You can find out more about Adaptive Cards including documentation, samples and more at adaptivecards.io.
Adaptive Cards Designer can be used to visually create the Card Structure for an Adaptive Card by dragging-and-dropping Card Elements including Containers, Elements and Inputs. Adaptive Cards Designer allows you to select Host App such as Widgets Board and can view your Adaptive Card in Light or Dark theme or in small, medium or large sizes. You can set properties for any Card Elements such as the data context for data binding along with any layout and styling along with content or visibility of elements along with being able to use the Card Payload Editor to edit or copy the JSON Schema or use the Sample Data Editor to test any databinding for an Adaptive Card. You can find the Adaptive Card Designer to create new cards visually including from a JSON Schema or sample at adaptivecards.io/designer.
Adaptive Card Schema defines the JSON structure including Card Elements of TextBlock, RichTextBlock and TextRun for text, Image for graphics or Media, MediaSource and CaptionSource for video. Containers can be used to arrange information within an Adaptive Card including Column, Table, FactSet and Fact to display key / value pairs. Actions include ToggleVisiblity with TargetElement to show or hide Card Elements or Submit to send Inputs from an Adaptive Card including Inputs like Text, Number, Date and Time along with ChoiceSet with Choice. Types are supported such as BackgroundImage to customise the look-and-feel of an Adaptive Card used for a Widget. You can find the Adaptive Card Schema by referring to the Schema Explorer at adaptivecards.io/explorer.
Widget Provider
Windows App SDK is used to develop modern native Windows applications using WinUI 3 for native UI components leveraging the latest functionality such as Widgets and is decoupled from Windows itself but instead delivered via NuGet and updated with new features and functionality every six months. Windows App SDK can be installed with the Windows application development Workload for Visual Studio to create WinUI 3 in Desktop apps to develop apps such as a Widget Provider using languages such as C++ with Win32 or C# with .NET. You can find out more about developing Windows App SDK apps using C++ with Win32 or C# with .NET at aka.ms/winappsdk.
Windows App SDK applications can become a Widget Provider by implementing the key methods from the IWidgetProvider and IWidgetProvider interfaces in Microsoft.Windows.Widgets.Providers namespace. IWidgetProvider includes Activate and Deactivate Methods for when Widgets Board is interested in updates including configuration information or it is not interested in updates from a Widget Provider. IWidgetProvider also includes CreateWidget and DeleteWidget for when a Widget has been added, including configuration information or when a Widget has been removed from the Widget Board along with OnActionInvoked which is triggered when an action has occurred in a Widget and WidgetContextChanged is triggered when the size of a Widget has been changed in the Widget Board. You can find out more about how to develop a Widget Provider for a Windows Widget using Windows App SDK at aka.ms/widgetdevdocs.
Windows App SDK applications using C# and .NET can become a Widget Provider even more easily using the Comentsys.Toolkit.WindowsAppSdk package that wraps Widget Provider functionality by Microsoft. WidgetProviderBase is a Class supporting key methods from IWidgetProvider and IWidgetProvider2 along with AddWidget and UpdateWidget for managing or registering Widgets from a Widget Provider. Windows App SDK and .NET Developers can also inherit a Base Class of WidgetBase to help implement the Widget including the returning Adaptive Card template and JSON data used for data binding. Comentsys.Toolkit.WindowsAppSdk can be found on NuGet, or you can get full source code along with an example Widget via comentsys.com/packages/toolkits.
Generative AI
ChatGPT uses an AI-powered natural language model created by OpenAI which also forms the basis of Microsoft Copilot which can assist with generating new ideas, reating content, streamlining tasks or refining information. These leverage AI models that are trained on large datasets that contain text, images or other type of content and can learn patterns or structure to draw on when generating output that can be fine-tuned with prompts. They can be used to generate new content such as images or text that can be tailored to specific themes or audiences by analysing input along with leveraging vast knowledge and utilising learned patterns or context. ChatGPT and Microsoft Copilot can simplify complex tasks by breaking them down into manageable steps along with providing clear instructions and insights to help guide users and can even when prompted be used to design user-friendly layouts for Adaptive Card templates for Windows Widgets that can be refined with further prompts. You can use ChatGPT for free by visiting chatgpt.com or Microsoft Copilot for free by visiting copilot.microsoft.com.
OpenAI Platform at openai.com/api provides developers with API access to powerful AI models for building applications with natural language processing and other AI-driven capabilities. Azure OpenAI Service at aka.ms/aoaiservice allows developers to leverage the full power of OpenAI models including fine-tuning of models using your own data with Azure AI Foundry. GitHub Models at github.com/models enables developers to experiment with models including those from OpenAI as well as those from other providers for free with usage limits.
Microsoft.Extensions.AI is a unified set of abstractions that standardises integration of AI services such as language models and embeddings for .NET developers that are available in preview on NuGet and provides a standard set of API interactions for use throughout an application for common tasks that work with any AI service provider along with caching, telemetry and more. Microsoft's goal is to provide standard implementations for developers and library authors are encouraged to implement Microsoft.Extensions.AI.Abstractions for other AI services.
Summary
Widgets in Windows 11 provide easy-to-use access to at-a-glance information with built-in and third-party Widgets from the Microsoft Store designed using Adaptive Cards. Adaptive Cards for Windows Widgets can be created with the online drag-and-drop designer, JSON schema or using generative AI to be delivered by a Widget Provider. Widget Provider for a Windows Widget can be created using Windows App SDK and Comentsys.Toolkit.WindowsAppSdk and can be powered with Generative AI and Generative AI can help generate content and more including Widgets and be easily integrated into .NET applications using Microsoft.Extensions.AI implementations.