private void yearwise_Loaded(object sender, RoutedEventArgs e) { noque nq = new noque(); Opt op = new Opt(); string st = nq.button2.Content.ToString(); string st2 = "ON"; if (st.Equals(st2)) { displayyearwise(); } else if (!(st.Equals(st2))) { displayyearwise(); } //displayyearwise(); }