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:
- add button control parent container.
- to assign name button, set x:name attribute string value. refer control in code, must have name. otherwise, name not required.
- to assign label button, set content property string value.
- 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" />
insidegrid
block inmainpage.xaml
. - i've added
void mainpage::button_click(object^ sender, routedeventargs^ e) {...}
inmainpage.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
Post a Comment