Using MEF to build a tabbed application dynamically?

Don't have intellisense handy, but I think you need to set the content of the item to be your page. Something like: foreach (var page in pages) { TabItem item = new TabItem(); item. Header = page.

PageTitle; item.Children. Add(page); //or item.Grid.Children. Add(page) or something like that.

// Add each page tcPageControl.Items. Add(item); }.

There aren't many details here - but the basic idea would be to Export each "page", potentially within a custom class that gives you page titles, etc. You'd then use ImportMany to import a collection of pages, and build a "tab" for each imported page.

This bit I think is working, in is the adding of each pages contents to the control that is failing. – Mmarquee Jun 13 '10 at 9:03.

You simply need to set the Content property of your TabItem to be the page, like this: foreach (var page in pages) { TabItem item = new TabItem(); item. Header = page. PageTitle; item.

Content = page; tcPageControl.Items. Add(item); } Here is a much more elegant way to code it using LINQ: tcPageControl. ItemsSource = from page in pages select new TabItem { Header = page.

PageTitle, Content = page, }; In general in WPF you never have to write a "foreach" loop if you structure your code correctly.

I solved my problem, Pages can only have Frames as their parents, so adding this code addresses it. Foreach (var page in pages) { TabItem item = new TabItem(); item. Header = page.

PageTitle; // Now add some controls Frame frame = new Frame(); frame. Content = page. View; item.

Content = frame; // Add each page tcPageControl.Items. Add(item); //tcPageControl.Children. Add(view.

Value); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions