locked
C# MainPage to C++

    Question

  • Here is the C# code

    public MainPage()

    InitializeComponent(); 

    Loaded += new RoutedEventHandler(MainPage_Loaded); 

    ...

    }

    void MainPage_loaded(object sender, RoutedEventArgs e)

    myMediaElement.MediaOpened += myMediaElement_MediaOpened; 

    ...

    }

    void myMeidaElement_MediaOpened(object sender, RoutedEvenetArgs e)

    { ... }

    How can I convert it to C++? Is Loaded a hide item in MainPage? Where is the URL about MainPage?


    Charlie Chang L

    Friday, August 17, 2012 5:38 PM

Answers

  • MainPage is a class defined in that project. There isn't a specific URL for it. It could be named anything.

    In this case, it probably inherits from the Page class, which ultimately inherits from FrameworkElement which has a Loaded event. MainPage_Loaded is the event handler function. Your clip looks like it has a bug: MainPage_Loaded and MainPage_loaded are probably supposed to be the same, but are different.

    If you generate a new C++ Windows Store app project in Visual Studio it will generate a similar MainPage object in C++.

    As far as converting to C++ goes, I'd take a look at the beginning C++ documentation, tutorials and samples starting with Tutorial: Create your first Metro style app using C++‎ and Roadmap for Metro style apps using C++

    --Rob

    Friday, August 17, 2012 10:36 PM
    Owner

All replies

  • MainPage is a class defined in that project. There isn't a specific URL for it. It could be named anything.

    In this case, it probably inherits from the Page class, which ultimately inherits from FrameworkElement which has a Loaded event. MainPage_Loaded is the event handler function. Your clip looks like it has a bug: MainPage_Loaded and MainPage_loaded are probably supposed to be the same, but are different.

    If you generate a new C++ Windows Store app project in Visual Studio it will generate a similar MainPage object in C++.

    As far as converting to C++ goes, I'd take a look at the beginning C++ documentation, tutorials and samples starting with Tutorial: Create your first Metro style app using C++‎ and Roadmap for Metro style apps using C++

    --Rob

    Friday, August 17, 2012 10:36 PM
    Owner
  • MainPage_loaded is a typo. It is MainPage_Loaded

    I tried to put MainPage_Loaded in the MainPage.xaml file like

    <common:LayoutAwarePage

      x:class= "..."

      ...

      Loaded="MainPage_Loaded">

    Main_Page has not been executed in C++.


    Charlie Chang L

    Saturday, August 18, 2012 3:55 AM
  • Have you defined the MainPage_Loaded method in your .h and .cpp files? If you don't then it won't exist to be called.

    You can let the designer generate the function prototypes for you by typing the event name ("Loaded=") and waiting a moment for the tooltip to offer to create a "<New Event Handler>".

    --Rob
    Saturday, August 18, 2012 5:32 AM
    Owner
  • Rebuild and work.

    Charlie Chang L

    Saturday, August 18, 2012 2:08 PM