Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to Programatically click a Button on a navigated Frame Page

How to Programatically click a Button on a navigated Frame Page

Scheduled Pinned Locked Moved WPF
csharptutorialasp-netwpf
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    Good Day all i am using Navigation service as depicted below

    <Frame x:Name="_home" NavigationUIVisibility="Hidden" HorizontalAlignment="Stretch" Width="2749" Margin="0,12,0,0" />

    and i navigate to the Page like this

            (Application.Current.MainWindow.FindName("\_home") as Frame).Source = new Uri("/F1.xaml", UriKind.Relative);
    

    which work fine. now in the Navigated page, lets just say a page shown in the Frame,there is some functionality like Calculate ,e.g that calculates Age based on the years(Example). Now from the Main Page i have a Button that says Calculate , i want to call the function or invoke a button click of Frame page from the Main Page. Well i have tried this from the main page

    private void btnCalculate_Click(object sender, RoutedEventArgs e)
    {
    F1 f1 = new F1();
    f1.CalculateYear();
    }

    no but does not work, the break-point does reach the F1 page but the UI does not have calculated results. One other thing i tried earlier is to pass the value that will be used in the calculation from the main , but when the one follow the variable value they just return an empty string when you follow it while stepping through it. How is this done Thanks

    Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

    V 1 Reply Last reply
    0
    • V Vimalsoft Pty Ltd

      Good Day all i am using Navigation service as depicted below

      <Frame x:Name="_home" NavigationUIVisibility="Hidden" HorizontalAlignment="Stretch" Width="2749" Margin="0,12,0,0" />

      and i navigate to the Page like this

              (Application.Current.MainWindow.FindName("\_home") as Frame).Source = new Uri("/F1.xaml", UriKind.Relative);
      

      which work fine. now in the Navigated page, lets just say a page shown in the Frame,there is some functionality like Calculate ,e.g that calculates Age based on the years(Example). Now from the Main Page i have a Button that says Calculate , i want to call the function or invoke a button click of Frame page from the Main Page. Well i have tried this from the main page

      private void btnCalculate_Click(object sender, RoutedEventArgs e)
      {
      F1 f1 = new F1();
      f1.CalculateYear();
      }

      no but does not work, the break-point does reach the F1 page but the UI does not have calculated results. One other thing i tried earlier is to pass the value that will be used in the calculation from the main , but when the one follow the variable value they just return an empty string when you follow it while stepping through it. How is this done Thanks

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      Found a Solution Changed this

      F1 f1 = new F1();

      to this

      F1 f1 = (F1 )_home.Content;

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups