Add data to tab in code

Sep 7, 2013 at 5:13 AM
Hello ,
I am currently using your project and i have a problem to pass data to Moderntab control.

Currently i have a collection of 'news' with data

News.cs
public News(int newsid, string newsauthor, string newsimage, string newstext, string newstitle, Dictionary<string, string> newsComments, string date)
        {
            NewsId = newsid;
            NewsAuthor = newsauthor;
            NewsImage = newsimage;
            NewsText = newstext;
            NewsTitle = newstitle;
            NewsComments = newsComments;
            NewsDate = date;
        }

        public string NewsTitle { get; set; }

        public Dictionary<string, string> NewsComments { get; set; }

        public string NewsText { get; set; }

        public string NewsImage { get; set; }

        public string NewsAuthor { get; set; }

        public int NewsId { get; set; }

        public string NewsDate { get; set; }
then when i load my main windows, i add all news by code like that
public void LoadAllNews()
        {
            foreach (var news in newsList)
            {
                ModernTab.Links.Add(new Link
                {
                    DisplayName = news.NewsTitle,
                    Source = new Uri("/Content/NewsContenair.xaml", UriKind.Relative)
                });
            }
        }
My probleme is how i can pass my news data to the NewsContenair and load it ?
Thanks by advance
Sep 7, 2013 at 6:04 AM
Edited Sep 7, 2013 at 7:32 AM
Found one solution
setting my NewsContenair as IContent , setting Source as new uri with NewsContenair.xaml+newsid, and display data with fragment as id.
that was simple in fact
Sep 25, 2013 at 8:23 AM
Please provide the code
Sep 26, 2013 at 10:19 AM
akhilmittal20, using the SheppeR sample , you can do:

Source = new Uri(String.Format("/Content/NewsContenair.xaml#{0}", news.Id), UriKind.Relative)
and on the SheppeR .xaml

public class NewsContenair: UserControl, IContent
{
  public void OnFragmentNavigation(FragmentNavigationEventArgs e)
  {
     var newsId = int.Parse(e.Fragment); //Can't recall if the # is in here, debug and see
     someViewModel.NewsId = newsId;
  }
  public void OnNavigatedFrom(NavigationEventArgs e)
  {
  }
  public void OnNavigatedTo(NavigationEventArgs e)
  {
  }
  public void OnNavigatingFrom(NavigatingCancelEventArgs e)
  {
  }
}