PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/TimeSheetReporting/TimeSheetReporting/MainPage.xaml.cs

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