c++ - 'Button_Click' : is not a member of 'ButtonTest::MainPage' -


i'm new c++ , windows store programming, , i'm stuck defining click handlers on buttons. i'm referring these instructions:

  1. add button control parent container.
  2. to assign name button, set x:name attribute string value. refer control in code, must have name. otherwise, name not required.
  3. to assign label button, set content property string value.
  4. to perform action when user clicks button, add handler click event. in click event handler, add code perform action.

<button x:name="button1" content="button" click="button_click" />

void mainpage::button_click(object^ sender, routedeventargs^ e) {
// add code perform action here.
}

  • i've added <button x:name="button1" content="button" click="button_click" /> inside grid block in mainpage.xaml.
  • i've added void mainpage::button_click(object^ sender, routedeventargs^ e) {...} in mainpage.xaml.cpp.

now 2 errors, can't resolve:

error c2039: 'button_click' : not member of 'buttontest::mainpage'

and

intellisense: class "buttontest::mainpage" has no member "button_click"

how can solve this?

you need define prototype of mainpage::button_click in mainpage.xaml.h file member of class. like

public:      button_click(object^, routedeventargs^); 

c++ needs prototype every method.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -