X
X
xeyas782021-10-29 08:48:27
WPF
xeyas78, 2021-10-29 08:48:27

Why is the button not hidden in WPF?

From the first script I try to hide the button from the second, but instead, nothing works. I installed a message box and it gives out the number 2 2 times when the button is pressed, what's the matter?

Second script:

using Service.AppDataFile;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Service.Pages;


namespace Service
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public static bool AdminPanel = false;

        public MainWindow()
        {
            InitializeComponent();
            ConnectOdb.conObj = new ServicePEntities();
            FrameObj.frameMain = frmMain;
            frmMain.Navigate(new PageLogin());
            LoadUpPanel();
        }
        
        public void LoadUpPanel()
        {
            if (AdminPanel == false)
            {
                MessageBox.Show("1");
                BtnBack.Visibility = Visibility.Hidden;
                BtnFaq.Visibility = Visibility.Hidden;
            }
            else if (AdminPanel == true)
            {
                MessageBox.Show("2");

                BtnBack.Visibility = Visibility.Visible;
                BtnFaq.Visibility = Visibility.Visible;
            }

            
        }


        
        
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            FrameObj.frameMain.Navigate(new PageMain());

        }

        private void btnFaq_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}

First
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Service.Pages
{
    /// <summary>
    /// Логика взаимодействия для PageLogin.xaml
    /// </summary>
    public partial class PageLogin : Page
    {
        public PageLogin()
        {
            InitializeComponent();

        }



        private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.AdminPanel = true;

            

            MainWindow main = new MainWindow();
            

            
            main.LoadUpPanel();

            
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question