locked
how to transwer a image one xaml to another xaml while clicking a button in metro style using c++ language.

    Question

  • how to transwer a image one xaml to another xaml while clicking a button in metro style using c++ language.
    Friday, July 20, 2012 3:11 AM

Answers

  • I believe this is what Sagar was suggesting. MainPage.XAML has two images, two buttons and a frame. There are two other XAML pages which the MainPage buttons use for displaying in the frame. When Page1 or Page2 load, they load the ImageSource passed in the Frame->Navigate call.

    //MainPage.XAML.cpp
    void FrameNavigationParamPassing::MainPage::b1_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	TypeName p1 = { "FrameNavigationParamPassing.Page1", TypeKind::Custom };
    	auto a = img1->Source;
    	f1->Navigate(p1, a);
    }
    
    void FrameNavigationParamPassing::MainPage::b2_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	TypeName p1 = { "FrameNavigationParamPassing.Page2", TypeKind::Custom };
    	auto a = img2->Source;
    	f1->Navigate(p1, a);
    }

    Code from one of the XAML pages loading in the frame that uses the ImageSource^ parameter.

    //Page1.XAML.cpp
    void Page1::OnNavigatedTo(NavigationEventArgs^ e)
    {
    	auto imgSource = dynamic_cast<Windows::UI::Xaml::Media::ImageSource^>(e->Parameter);
    	//Set the Page1 Image source property
    	i1->Source = imgSource;
    }


    David Lamb

    • Marked as answer by Bilaal John S Thursday, July 26, 2012 11:49 AM
    Wednesday, July 25, 2012 5:28 PM
    Moderator
  • iam tring but not happening...I wrote a page navigation code.its working....I really want the image navigation code...the page navigation code as follows.

    TypeName

    pageType = {"CameraApp.Calender", TypeKind::Custom};

    this->Frame->Navigate( pageType, this);

    • Marked as answer by Bilaal John S Friday, July 27, 2012 5:26 AM
    Monday, July 23, 2012 6:21 AM

All replies

  • Hi Sarath,

    When you say transfer do you mean from from XAML page to another? If so, then you can pass it as a parameter while navigating to the other XAML page with Frame::Navigate.

    -Sagar

    Friday, July 20, 2012 3:34 PM
    Moderator
  • Hi,

    thank you for your valuable comments.

    Regards,

    Sarath s

    Monday, July 23, 2012 6:18 AM
  • iam tring but not happening...I wrote a page navigation code.its working....I really want the image navigation code...the page navigation code as follows.

    TypeName

    pageType = {"CameraApp.Calender", TypeKind::Custom};

    this->Frame->Navigate( pageType, this);

    • Marked as answer by Bilaal John S Friday, July 27, 2012 5:26 AM
    Monday, July 23, 2012 6:21 AM
  • I believe this is what Sagar was suggesting. MainPage.XAML has two images, two buttons and a frame. There are two other XAML pages which the MainPage buttons use for displaying in the frame. When Page1 or Page2 load, they load the ImageSource passed in the Frame->Navigate call.

    //MainPage.XAML.cpp
    void FrameNavigationParamPassing::MainPage::b1_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	TypeName p1 = { "FrameNavigationParamPassing.Page1", TypeKind::Custom };
    	auto a = img1->Source;
    	f1->Navigate(p1, a);
    }
    
    void FrameNavigationParamPassing::MainPage::b2_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	TypeName p1 = { "FrameNavigationParamPassing.Page2", TypeKind::Custom };
    	auto a = img2->Source;
    	f1->Navigate(p1, a);
    }

    Code from one of the XAML pages loading in the frame that uses the ImageSource^ parameter.

    //Page1.XAML.cpp
    void Page1::OnNavigatedTo(NavigationEventArgs^ e)
    {
    	auto imgSource = dynamic_cast<Windows::UI::Xaml::Media::ImageSource^>(e->Parameter);
    	//Set the Page1 Image source property
    	i1->Source = imgSource;
    }


    David Lamb

    • Marked as answer by Bilaal John S Thursday, July 26, 2012 11:49 AM
    Wednesday, July 25, 2012 5:28 PM
    Moderator
  • thankz David..
    Thursday, July 26, 2012 5:45 AM