WidgetManager.DeleteWidget(String) Method
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.
Requests the removal of a widget from the widget host.
public:
virtual void DeleteWidget(Platform::String ^ widgetId) = DeleteWidget;
void DeleteWidget(winrt::hstring const& widgetId);
public void DeleteWidget(string widgetId);
function deleteWidget(widgetId)
Public Sub DeleteWidget (widgetId As String)
Parameters
- widgetId
-
String
Platform::String
winrt::hstring
The unique identifier of the widget to remove. The widget ID value is dynamically generated by the WidgetManager. The widget ID remains the same for a widget from the moment of its creation until the moment the Widget is deleted. The widget ID is a unique value across all widgets and all widget providers.
Implements
Examples
The following example deletes all of the widgets with a specified .
/*
* Sample output:
* Deleted Widget with Id: {D8FEC89F-9A89-44B1-A52D-F04C515B0141}
*/
using namespace std;
using namespace winrt;
class WidgetManagerOperations
{
void DeleteAllClockWidgets()
{
WidgetManager widgetManager = WidgetManager::GetDefault();
com_array<WidgetInfo> widgetInfos = widgetManager.GetWidgetInfos();
for (const auto& widgetInfo : widgetInfos)
{
if (widgetInfo.WidgetContext().DefinitionName() == L"clockWidget")
{
hstring widgetId = widgetInfo.WidgetContext().Id();
widgetManager.DeleteWidget(widgetId);
wcout << L"Deleted Widget with Id: " << widgetId << endl;
}
}
}
}
Remarks
After this method has been called, your provider will receive a notification that the widget has been deleted through the DeleteWidget method.
Calling this method with the ID of a widget that has already been deleted will have no effect.