PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/TimeSheetReporting/TimeSheetReporting/MainPage.xaml.cs

#
C# | 51 lines | 46 code | 3 blank | 2 comment | 5 complexity | be716700b648259cb68a2cbb06f46180 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Navigation;
  12. using System.Windows.Shapes;
  13. namespace TimeSheetReporting
  14. {
  15. public partial class MainPage : UserControl
  16. {
  17. public MainPage()
  18. {
  19. InitializeComponent();
  20. }
  21. // After the Frame navigates, ensure the HyperlinkButton representing the current page is selected
  22. private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
  23. {
  24. foreach (UIElement child in LinksStackPanel.Children)
  25. {
  26. HyperlinkButton hb = child as HyperlinkButton;
  27. if (hb != null && hb.NavigateUri != null)
  28. {
  29. if (hb.NavigateUri.ToString().Equals(e.Uri.ToString()))
  30. {
  31. VisualStateManager.GoToState(hb, "ActiveLink", true);
  32. }
  33. else
  34. {
  35. VisualStateManager.GoToState(hb, "InactiveLink", true);
  36. }
  37. }
  38. }
  39. }
  40. // If an error occurs during navigation, show an error window
  41. private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
  42. {
  43. e.Handled = true;
  44. ChildWindow errorWin = new ErrorWindow(e.Uri);
  45. errorWin.Show();
  46. }
  47. }
  48. }