Parameters
- item
- The item to retrieve from the favorite collection.
Return Value
The favorite item or null if the item is not a part of the favorite collection.
var itemFolder = ItemFactory.Instance.Create(@"d:\data"); // is the folder item already a favorite? var fav = FavoritesManager.Current.GetFavorite(itemFolder); if (fav == null) { if (FavoritesManager.Current.CanAddAsFavorite(itemFolder)) { fav = FavoritesManager.Current.AddFavorite(itemFolder); } }
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); }
StyleProjectItem styleItem = Project.Current.GetItems<StyleProjectItem>(). FirstOrDefault(style => (style.Name == "ArcGIS 3D")); if (FavoritesManager.Current.CanAddAsFavorite(styleItem)) { // add to favorites with IsAddedToAllNewProjects set to false FavoritesManager.Current.AddFavorite(styleItem); }
var itemFolder = ItemFactory.Instance.Create(@"d:\data"); // is the folder item already a favorite? var fav = FavoritesManager.Current.GetFavorite(itemFolder); if (fav != null) { if (fav.IsAddedToAllNewProjects) FavoritesManager.Current.ClearIsAddedToAllNewProjects(fav.Item); else FavoritesManager.Current.SetIsAddedToAllNewProjects(fav.Item); }
Target Platforms: Windows 11, Windows 10