0

I have created one window and declared 2 instances of my object, then I modified them and wanted to pass to another Window. My questions are:

  • How would i do that ?
    (I can pass simple types such as string or int trough window constructor but passing my own object giving me an error (Inconsistent Accessibility parameter order is less accessible then method))

  • Does it have any connection with dataContext ?

Can anybody explain to me how I can achieve that (in the simplest possible way)? What are the correct ways to do that ? Here is part of my code (everything is in one namespace):

public partial class Main_window : Window
{
    Order myOrder = new Order();
    Menu menu = new Menu();

    public Main_window()
    {  InitializeComponent()  }
    private void OpenSecondWindow(object sender, RoutedEventArgs e)
    {
            Second_Window SecondWindow = new Second_Window();
            Second.ShowDialog(); 
    }
}

// Second Window class
public partial class Second_Window : Window
{
  public Second_Window(Order someOrder)
    {   InitializeComponent();   }
} 
0

1 Answer 1

1

Make sure that the Order type, and any other type you intend to inject the SecondWindow with, is defined as a public class:

public class Order { ... }

A non-public type cannot be part of the signature of a public method or constructor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.