Parameters
- item
- The item to be checked to see if it's a favorite candidate.
Return Value
True if the item can be made a favorite. False otherwise
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); }
Target Platforms: Windows 11, Windows 10