This is a migrated thread and some comments may be shown as answers.

Dynamically created TransPages and PageUri = ???

1 Answer 64 Views
TransitionControl
This is a migrated thread and some comments may be shown as answers.
Ramjet
Top achievements
Rank 1
Ramjet asked on 19 Aug 2011, 11:31 PM
Hello,

My wpf application has a UserControl that host a transition control. The transition control gets it's TransPages loaded in code.

#region Create our singleton that has the default pages
 
                //add our pages...hard coded for now
                TransPage tp_MVW = new TransPage();
                tp_MVW.DisplayName = "MVW";
                tp_MVW.PageUri = "/SSODemo;component/uc_MVW_Host.xaml";
 
                TransPage tp_MediT = new TransPage();
                tp_MediT.DisplayName = "MediTech";
                tp_MediT.PageUri = "/SSODemo;component/uc_TechHost.xaml";
 
                TransPage tp_Google = new TransPage();
                tp_Google.DisplayName = "Google";
                tp_Google.PageUri = "/SSODemo;component/uc_Google_Host.xaml";
 
                Props.TransitionMap = TransMap.Single_TransMap;
 
                Props.TransitionMap.Pages.Add(tp_MVW);
                Props.TransitionMap.Pages.Add(tp_MediT);
                Props.TransitionMap.Pages.Add(tp_Google);
 
            #endregion

and everything works as it should. Now these three user controls, as you can see, are static files in the project with a physical path. All three of the controls have a WPF WebBrowser control. What happens when a user clicks a hyperlink in one of these browsers that opens has target=_blank and a new window opens. Well yes a new window opens OUTSIDE of the WPF application. No worries I added the needed hooks and now intercept that new window opening event. At this point what I want to do is create a new control with a WebBrowser on it and send it to the desired url. THEN I want to add it to the TransPages so it shows in the list of windows to transition between. My question is two fold. What method would you recommend for dynamically generating the user control (I have an idea about using ControlTemplate) and more importantly HOW would I add this "UserControl object" to the PageUri when it is expecting a physical path?
TIA
JB


that host a webbrowser. This loads great and all is well. Next the user clicks on a link and a new browser window opens outside of the wpf app. This makes sense since the wpf browser is just a wrapper and not a true WPF control. So I intercept the new window event and this is where it gets tricky. I want to load the page being opened in a new usercontrol's web browser control. In other words repeat the situation by which my app opens dynamically.

So I thought about creating a "NewWebPage" UserControl template. Great I could use it one time. The next click no more NewWebPage template as it has been used. (well technically I could reuse it but then the current page would be lost) What I would really like to do is use the NewWebPage template as a template. Would a DataTemplate be the way to go for this? If so how exactly as I've not used one in this way before.

1 Answer, 1 is accepted

Sort by
0
Ramjet
Top achievements
Rank 1
answered on 22 Aug 2011, 02:37 PM
I have learned something about WPF that I didn't know when posting. Explained in comments.
void MainWindow_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl)
        {
            #region
 
                /*WPF is very different than traditional technology. WPF is completely "template" based
                 * traditionally you think of a gui and you shove data into it but WPF is different.
                 * instead think of it as data that we wrap with a template.
                 * so in the next line below you'll see we CAN use the same xaml page no matter how many windows are opened
                 * because of this templated data concept.*/
 
            //well we are here because they clicked on a web browser link.
            //Add the page being opened to the pages collection
            TransPage NewPage = new TransPage();
            NewPage.DisplayName = "New";
            NewPage.PageUri = "/SSODemo;component/uc_WebPgTemp.xaml";
             
            Props.TransitionMap.Pages.Add(NewPage);
 
            #endregion
 
        }
Tags
TransitionControl
Asked by
Ramjet
Top achievements
Rank 1
Answers by
Ramjet
Top achievements
Rank 1
Share this question
or