Home Ask Login Register

Developers Planet

Your answer is one click away!

Huma Ali February 2016

Which event is fired when Content property is changed

I have two Pages ProductSearch,ProductDetail and Im changing the Content property to Navigate between Pages. I want to know if any events are fired so I can write some code in it?

On ProductDetail Page I have UIElement property

public UIElement MainContent { get; set; }

On ProductSearch Page I Navigate to ProductDetail By setting the Content property like this:

 private void OnGetDetailsClick(object sender, RoutedEventArgs e)
    ProductDetail productDetail = new ProductDetail();
    productDetail.MainContent = this.Content;
    this.Content = productDetail;

On ProductDetail Page's Back Button I navigate back to ProductSearch:

private void OnBackButtonClick(object sender, RoutedEventArgs e)
  this.Content = MainContent;

Now I want to know how can I call a method when I navigate Back to ProductSearch Page i.e how would I know that I have Navigated from ProductDetail Page? I tried to check if it loads the page but found out that When you change content of control it doesn't fire the load event of the page. Any solution?


silverfighter February 2016

Yea this will not execute the load event since your are only changing the content obviously.

if you want to take advantage of navigation you should check out this video. Even if its done with blend the concepts apply also with Visual STudio: https://vimeo.com/6599527 (Simple Silverlight Master/Detail Navigation App with Blend 3)

You should check out articles on master detail binding like this one: https://msdn.microsoft.com/en-us/library/cc645060(v=vs.95).aspx

The key is to take advantage of the powerful binding concepts which come with silverlight. And if you are not using deep linking you might want to consider using a user control to hide/show details instead of a extra page.


Post Status

Asked in February 2016
Viewed 2,515 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life