InsertFavorite(Item,Int32) Method
Inserts an item to the favorites collection. The item is added to the collection with the
Favorite.IsAddedToAllNewProjects value set to false.
Parameters
- item
- The item to add to the favorite collection. For example a folder connection or a toolbox.
- index
- The index at which the item is to be inserted.
Return Value
The favorite item. Null if the item cannot be added as a favorite.
Insert a Favorite - Geodatabase path
string gdbPath = "@C:\\myDataFolder\\myData.gdb";
var itemGDB = ItemFactory.Instance.Create(gdbPath);
// is the item already a favorite?
var fav = FavoritesManager.Current.GetFavorite(itemGDB);
// no; add it with IsAddedToAllNewProjects set to true
if (fav != null)
{
if (FavoritesManager.Current.CanAddAsFavorite(itemGDB))
FavoritesManager.Current.InsertFavorite(itemGDB, 1, true);
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.