Hello,
I also have WindowWPF classes (WPFPage1, WPFPage2).
When I click AddWPF1 button I want an instance of the WPFPage1 with some details (WPFPage2 WPFPage, string formType, string contentname1, string textboxtext, string labelContent) to open in Grid1. And similar with the AddWPF2 button.
At present I can only use WPFPage1 or WPFPage2 (by changing the WPFPage1 or WPFPage2 in this line public void addFormToGrid(WPFPage1 WPFPage, string formType, string contentname1, string textboxtext, string labelContent).
I have attached a full working example with code with WFPPage2 button commented out so that it works.
Still getting my head around OOP so could someone please show me where I’m going wrong here.
Tony.
Nigel FernandesPosted Jan 28, 2017, 8:11 PM
Nigel FernandesPosted Jan 29, 2017, 12:09 AM
Tony AllanPosted Jan 28, 2017, 8:23 PM
Tony AllanPosted Jan 28, 2017, 8:01 PM
Nope, sorry Nigel
a little more complicated than that. Did you test it?
I changed
public void addFormToGrid(WPFPage1 WPFPage, string formType, string contentname1, string textboxtext, string labelContent)
To
public void addFormToGrid(Object WPFPage, string formType, string contentname1, string textboxtext, string labelContent)
and also did exacltly as you said
public void addFormToGrid(Object obj, string formType, string contentname1, string textboxtext, string labelContent)
(just to be literal).
Both created errors in this part of the code.
content1 = (Grid)WPFPage.Content;
WPFPage.Content = null;
content1.Name = contentname1;
WPFPage.textBox.Text = textboxtext;
WPFPage.label.Content = labelContent;
Grid1.Children.Add(content1);
content, textbox and label (highlighted in Red) all bring up this fault code.
'object' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Thanks for the effort.
Tony
Nigel FernandesPosted Jan 28, 2017, 7:10 PM