3

I want to do something like this:

var iFrame = new Frame();
var iPage = new Page(new Uri("/Views/MyPage.xaml", UriKind.Relative));
//                              ^ this must be the parameter on creating the page

iFrame.Content = iView;
tabCtrl.Content = iFrame;

Wherein, I want to open the page using the path instead of instantiating the page itself which is functionally correct like this:

var iFrame = new Frame();
var iPage = new MyPage();

iFrame.Content = iView;
tabCtrl.Content = iFrame;

My idea is to use a maintained path for the Page stored in the database. Any thoughts?

Mark
  • 8,046
  • 15
  • 48
  • 78
  • How about using an user control instead for a page? so that you can add it's object directly to the tabbed control, – sujith karivelil Dec 09 '15 at 05:40
  • Please elaborate? I need to have the path as the parameter. – Mark Dec 09 '15 at 05:46
  • see if the following answer helps http://stackoverflow.com/questions/24221571/modern-ui-wpf-navigation/24228627#24228627 – pushpraj Dec 09 '15 at 05:53
  • Thank you @pushpraj, but I am looking for something like how I can instantiate the existing page using that URI then add it as content/ – Mark Dec 09 '15 at 05:57
  • are you getting an error of any sort? it looks like you may need to escape your "/"'s i.e. `@"/Views/MyPage.xaml" ` or `"//Views//MyPage.xaml", – Mark Hall Dec 09 '15 at 06:06

2 Answers2

3

Something like this?

    System.Uri resource =  new System.Uri(@"Views\MyPage.xaml", System.UriKind.RelativeOrAbsolute);
    Something.Content = System.Windows.Application.LoadComponent(resource);
Tyress
  • 3,573
  • 2
  • 22
  • 45
0

Let myUserControl.xaml be the user control, then you can add this user control to the tabbed item as like the following;

myUserControl myUserControlObject= new myUserControl();
tabCtrl.Content=myUserControlObject;

and you have to import the myUserControl class like: using project.Views since it belongs to view namespace. check whether a page can be added like this or not

sujith karivelil
  • 28,671
  • 6
  • 55
  • 88