Answered by:
Passing class objects as arguments in Windows 8 App and receive them on click event

Question
-
The objects passed as arguments are only received an Navigation event. I want to receive them on Click Event,what should I use instead of Parameter??
void App1::MainPage::btuN_Click(Platform::Object^ sender,Windows::UI::Xaml::RoutedEventArgs^ e) { Variables^ data = (Variables^)e->OriginalSource; if (data->sNotf!=nullptr) Frame->Navigate(TypeName(BlankPage3::typeid), data); }
I used OriginalSource, but it didn't work. Would any one help me? Thanks in Advance!
Saturday, March 16, 2013 7:00 PM
Answers
-
Hi,
I tested this on my side, but cannot reproduce this issue.
oid App3::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { Object^ data=e->OriginalSource; //Variables^ data = (Variables^)e->OriginalSource; if (data!=nullptr) Frame->Navigate(TypeName(BlankPage::typeid), data); } void BlankPage::OnNavigatedTo(NavigationEventArgs^ e) { //(void) e; // Unused parameter Object^ data=e->Parameter; }
And based on your codes, you pass a data to another page. If you want to pass value in different pages, please follow this thread.
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/8cb42356-82bc-4d77-9bbc-ae186990cfd5/Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Jesse Jiang Friday, March 22, 2013 1:29 AM
Monday, March 18, 2013 6:01 AM -
Hi,
In this situation, I would suggest you to store the value in local settings instead of pass the value between pages. In this way, different pages can access the data.
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh700361(v=win.10).aspxBest regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Jesse Jiang Friday, March 22, 2013 1:29 AM
Tuesday, March 19, 2013 3:03 AM -
Deleted
- Marked as answer by Jesse Jiang Friday, March 22, 2013 1:29 AM
Tuesday, March 19, 2013 10:09 AM
All replies
-
- Edited by Mokarrom Hossain Monday, March 18, 2013 4:55 AM
Monday, March 18, 2013 4:55 AM -
Hi,
I tested this on my side, but cannot reproduce this issue.
oid App3::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { Object^ data=e->OriginalSource; //Variables^ data = (Variables^)e->OriginalSource; if (data!=nullptr) Frame->Navigate(TypeName(BlankPage::typeid), data); } void BlankPage::OnNavigatedTo(NavigationEventArgs^ e) { //(void) e; // Unused parameter Object^ data=e->Parameter; }
And based on your codes, you pass a data to another page. If you want to pass value in different pages, please follow this thread.
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/8cb42356-82bc-4d77-9bbc-ae186990cfd5/Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Jesse Jiang Friday, March 22, 2013 1:29 AM
Monday, March 18, 2013 6:01 AM -
The page, on which I passed object and receive on OnNavigatedTo event, is to be accessed by another page as well. So it gives an error whenever I navigate from a page from which I am not interested to pass an object. That's the problem, Sir!Monday, March 18, 2013 7:26 AM
-
The page, on which I passed object and receive on OnNavigatedTo event, is to be accessed by another page as well. So it gives an error whenever I navigate from a page from which I am not interested to pass an object. That's the problem, Sir!Monday, March 18, 2013 7:27 AM
-
Hi,
In this situation, I would suggest you to store the value in local settings instead of pass the value between pages. In this way, different pages can access the data.
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh700361(v=win.10).aspxBest regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Jesse Jiang Friday, March 22, 2013 1:29 AM
Tuesday, March 19, 2013 3:03 AM -
A big thanks to all, I am very grateful, Sir!Tuesday, March 19, 2013 7:10 PM