private void OnManagementPivotSelectionChanged(object sender, SelectionChangedEventArgs e) { var obj = e.AddedItems[0] as DependencyObject; if (obj == null) return; var section = DataExtensions.GetManagementSection(obj); SelectedManagementSection = section; switch (section) { case ManagementSection.SearchResults: AppBar.Buttons.Add(_pinSelectedSearchResultButton); break; default: AppBar.Buttons.Remove(_pinSelectedSearchResultButton); break; } }
public static void SetManagementSection(DependencyObject obj, ManagementSection value) { if (obj == null) throw new ArgumentNullException("obj", "Unable to set management section on null dependency object"); obj.SetValue(ManagementSectionProperty, value); }