controler un bouton d'une page apartir d'une autre page silverlight
voila mon pb c que j'au 2 pages : MainPages.cs et Home.cs
dans home page ya un bouton pour controler un bouton sur MaiPage
mon code :
le message s'affiche mais pour le bouton link2 ne change pas :calim2: ?????
Home.cs
Code:
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
| public partial class Home : Page
{
/// <summary>
/// Creates a new <see cref="Home"/> instance.
/// </summary>
public Home()
{
InitializeComponent();
this.Title = ApplicationStrings.HomePageTitle;
}
/// <summary>
/// Executes when the user navigates to this page.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
MainPage.Instance.test();
}
} |
ma page MainPage
Code:
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
| public partial class MainPage : UserControl
{
private static MainPage _Instance;
public static MainPage Instance
{
get
{
if (_Instance == null) _Instance = new MainPage();
return _Instance;
}
}
/// <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);
}
public void test()
{
System.Windows.MessageBox.Show("gggggghhhhhxxxxxxxxhbbbbbbxxxxxxxx");
//link2.Visibility = System.Windows.Visibility.Collapsed;
MainPage.Instance.Link2.Visibility = System.Windows.Visibility.Visible;
}
} |