1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
namespace test_passage_paramaitre
{
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using test_passage_paramaitre.LoginUI;
using System.Windows.Data;
using System.Globalization;
using System;
/// <summary>
/// <see cref="UserControl"/> class providing the main UI for the application.
/// </summary>
public partial class MainPage : UserControl
{
/// <summary>
/// Creates a new <see cref="MainPage"/> instance.
/// </summary>
public MainPage()
{
InitializeComponent();
this.loginContainer.Child = new LoginStatus();
}
/// <summary>
/// After the Frame navigates, ensure the <see cref="HyperlinkButton"/> representing the current page is selected
/// </summary>
private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
{
foreach (UIElement child in LinksStackPanel.Children)
{
HyperlinkButton hb = child as HyperlinkButton;
if (hb != null && hb.NavigateUri != null)
{
if (hb.NavigateUri.ToString().Equals(e.Uri.ToString()))
{
VisualStateManager.GoToState(hb, "ActiveLink", true);
}
else
{
VisualStateManager.GoToState(hb, "InactiveLink", true);
}
}
}
}
/// <summary>
/// If an error occurs during navigation, show an error window
/// </summary>
private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
e.Handled = true;
ErrorWindow.CreateNew(e.Exception);
}
}
[ValueConversion(typeof(string), typeof(Visibility))]
public class NameToVisibilityConverter : IValueConverter
{
public string Name { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string s = (string)value;
if (Name == value)
return Visibility.Visible;
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
} |
Partager