W jaki sposób przekazać wskaźnik do jakiejś klasy z klasy głównej do dialogu?

0

Wiajcie!
Mam klasę główną:

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            TicketManagement = new ticket_management();
            Fill_MainMenu();
        }
        void Fill_MainMenu()
        {
            hMainMenu.Items.Add("Sprzedaj bilet");
            hMainMenu.Items.Add("Sprawdź bilet");
            hMainMenu.Items.Add("Wyszukaj połączenie");
        }

        ticket_management TicketManagement;
        

        private void hExecute_Click(object sender, RoutedEventArgs e)
        {
            string result = hMainMenu.Text.ToString();
            if(result == "Sprzedaj bilet")
            {
                DialogSellTicket hWsk = new DialogSellTicket(); 

Przy tworzeniu dialogu próbowałem przekazać obiekt TicketManagement już chyba na wszystkie sposoby do konstruktora DialogSellTicket() i nie działa :( Dysponujecie jakimś linkiem co mi pomoże rozwiązać problem? Używałem referencji, wskaźnika, object i nic :(

No chyba, że znacie inny sposób jak użyć metody z TicketManagement z poziomu Dialogu.

0

A co przyjmuje to konstruktor tego DialogSellTicket ?

Jak oczekuje obiektu ticket_management to wołasz to normalnie new DialogSellTicket(TicketManagement);

A tak swoją drogą to tragiczne i nieczytelne nazewnictwo...

0
public partial class DialogSellTicket : Window
    {
        public DialogSellTicket(ticket_management cClass)
        { 
DialogSellTicket hWsk = new DialogSellTicket(TicketManagement); 

error CS0051: Inconsistent accessibility: parameter type 'KupBilet.ticket_management' is less accessible than method 'KupBilet.DialogSellTicket.DialogSellTicket(KupBilet.ticket_management)'

2

A klasa ticket_management jest publiczna?

0

W C# klasy są niejawnie prywatne więc sprawdź jak jest z Twoją TicketManagement

1 użytkowników online, w tym zalogowanych: 0, gości: 1