private async void LocationPanel_DeleteClick(object sender, RoutedEventArgs e) { FrameworkElement button = sender as FrameworkElement; if (button == null || (button != null && button.DataContext == null)) { return; } LocationPanelViewModel view = button.DataContext as LocationPanelViewModel; LocationData data = view.LocationData; // Remove location from list await Settings.DeleteLocation(data.query); // Remove panel LocationPanels.Remove(view); // Remove secondary tile if it exists if (SecondaryTileUtils.Exists(data.query)) { await new SecondaryTile( SecondaryTileUtils.GetTileId(data.query)).RequestDeleteAsync(); } }
private async void PinButton_Click(object sender, RoutedEventArgs e) { var pinBtn = sender as AppBarButton; pinBtn.IsEnabled = false; if (SecondaryTileUtils.Exists(location.query)) { bool deleted = await new SecondaryTile( SecondaryTileUtils.GetTileId(location.query)).RequestDeleteAsync(); if (deleted) { SecondaryTileUtils.RemoveTileId(location.query); } SetPinButton(!deleted); GetPinBtn().IsEnabled = true; } else { // Initialize the tile with required arguments var tileID = DateTime.Now.Ticks.ToString(); var tile = new SecondaryTile( tileID, "SimpleWeather", "action=view-weather&query=" + location.query, new Uri("ms-appx:///Assets/Square150x150Logo.png"), TileSize.Default); // Enable wide and large tile sizes tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); // Add a small size logo for better looking small tile tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.png"); // Add a unique corner logo for the secondary tile tile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png"); // Show the display name on all sizes tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; bool isPinned = await tile.RequestCreateAsync(); if (isPinned) { // Update tile with notifications SecondaryTileUtils.AddTileId(location.query, tileID); await WeatherTileCreator.TileUpdater(location); await tile.UpdateAsync(); } SetPinButton(isPinned); GetPinBtn().IsEnabled = true; } }