Retrieves the set of favorites from the favorite collection.
Get the set of favorites and iterate
var favorites = FavoritesManager.Current.GetFavorites();
foreach (var favorite in favorites)
{
bool isAddedToAllProjects = favorite.IsAddedToAllNewProjects;
// retrieve the underlying item of the favorite
Item item = favorite.Item;
// Item properties
var itemType = item.TypeID;
var path = item.Path;
// if it's a folder item
if (item is FolderConnectionProjectItem)
{
}
// if it's a goedatabase item
else if (item is GDBProjectItem)
{
}
// else
}
Remove All Favorites
var favorites = FavoritesManager.Current.GetFavorites();
foreach (var favorite in favorites)
FavoritesManager.Current.RemoveFavorite(favorite.Item);
FavoritesChangedEvent
ArcGIS.Desktop.Core.Events.FavoritesChangedEvent.Subscribe((args) =>
{
// favorites have changed
int count = FavoritesManager.Current.GetFavorites().Count;
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.