private void FavoriteItemClicked(object sender, RoutedEventArgs e) { IFavoriteItem favItem = ((Button)sender).DataContext as IFavoriteItem; if (favItem.Command != null) { favItem.Command(); } }
private void AddToFavorites() { Debug.Assert(NavigationService != null); Debug.Assert(Container != null); string fullPath = System.IO.Path.Combine(NavigationService.CurrentPath, NavigationService.SelectedItem); IFavoriteItem favItem = null; if (Directory.Exists(fullPath)) { favItem = new FavoriteDirectoryItem(fullPath); } else if (File.Exists(fullPath)) { favItem = new FavoriteFileItem(fullPath); } if (favItem != null) { CompositionBatch batch = new CompositionBatch(); batch.AddPart(favItem); Container.Compose(batch); } }