locked
How to navigate image source to another xaml? c# windows store app RRS feed

  • Question

  • i want to navigate txtBox1.text and bg2.source to another xaml at the same time

    i try to use this

    private void button1_Click(object sender, RoutedEventArgs e)
            {

                this.Frame.Navigate(typeof(MultiGame), bg2.Source);

                this.Frame.Navigate(typeof(MultiGame), txtBox1.text);

            }

    it doesnt work. I hope someone can help me!!!

    Saturday, January 4, 2014 8:39 AM

Answers

  • Decalre class in another class file.

    private void button1_Click(object sender, RoutedEventArgs e)
            {
            }


    file : abc.cs:

    public class abc
        {
            public string str1 { get; set; }
            public ImageSource image1 { get; set; }
        }

    button click event:

    private void button1_Click(object sender, RoutedEventArgs e)
            {
             abc a1 = new abc();
    a1.str = txtbox1.text;
    a1.image1 = bg2;
    this.Frame.Navigate(typeof(MultiGame),a1);
            }

    multigame.xaml.cs :

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                abc a1 = e.Parameter as abc;
                Debug.WriteLine(a1.str);
                image.Source = a1.image1;
            }

    Saturday, January 4, 2014 11:00 AM

All replies

  • Hello NewbieDeveloperWindowsStoreAp, 

    try to use class. Like :

     public class abc
        {
            public string str1 { get; set; }
            public ImageSource image1 { get; set; }
        }

    abc a1 = new abc(); a1.str = txtbox1.text; a1.image1 = bg2;

    this.Frame.Navigate(typeof(MultiGame),a1);



    • Edited by Khant Nipun Saturday, January 4, 2014 9:30 AM
    Saturday, January 4, 2014 9:27 AM
  • mister im really sorry how can i use a1 in Multigame.xaml.cs?

    because when i this this.Frame.Navigate(typeof(MultiGame), txtBox1.text);

    the code i put in multigame.xaml.cs is e.Parameter.tostring(); this is i know so far.

    help me please?

    Saturday, January 4, 2014 10:15 AM
  • Hello NewbieDeveloperWindowsStoreAp, 

    You can get in multigame.xaml.cs :

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                abc a1 = e.Parameter as CustomerMap1;
                Debug.WriteLine(a1.str);
                image.Source = a1.image1;
            }

    Saturday, January 4, 2014 10:19 AM
  • i got 2 errors abc and customermap1 could not found.

    by the way sir i declared the the class abc in

     public class abc
            {
                public string str1 { get; set; }
                public ImageSource image1 { get; set; }
            }
            public MainPage()
            {

                this.InitializeComponent();
            }

    Saturday, January 4, 2014 10:29 AM
  • Sorry:

    try this code :

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                abc a1 = e.Parameter as abc;
                Debug.WriteLine(a1.str);
                image.Source = a1.image1;
            }

    Saturday, January 4, 2014 10:37 AM
  • error show this (The type or namespace name 'abc' could not be found)

    i try to declare another public class abc but it doesnt work also


    Saturday, January 4, 2014 10:47 AM
  • Decalre class in another class file.

    private void button1_Click(object sender, RoutedEventArgs e)
            {
            }


    file : abc.cs:

    public class abc
        {
            public string str1 { get; set; }
            public ImageSource image1 { get; set; }
        }

    button click event:

    private void button1_Click(object sender, RoutedEventArgs e)
            {
             abc a1 = new abc();
    a1.str = txtbox1.text;
    a1.image1 = bg2;
    this.Frame.Navigate(typeof(MultiGame),a1);
            }

    multigame.xaml.cs :

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                abc a1 = e.Parameter as abc;
                Debug.WriteLine(a1.str);
                image.Source = a1.image1;
            }

    Saturday, January 4, 2014 11:00 AM
  • If you have path of your image source than, you can send path to next page.
    Saturday, January 4, 2014 11:03 AM
  • thank you so much mister you really help.

    thank you also for being patient. im really sorry im too new in this!

    Saturday, January 4, 2014 11:11 AM
  • 1 more question i want to use this abc a1 = e.Parameter as abc; in : 

    private void Button_Click(object sender , RoutedEventArgs e )
            {
            }

    but when i try to declare: 

    abc a1 = e.Parameter as abc; the Parameter does not show

    Saturday, January 4, 2014 11:20 AM
  • i get it

    i declare string on Multigame :

    public sealed partial class MultiGame : Page
        {
            string myVar = string.Empty;
            public MultiGame()
            {
                this.InitializeComponent();
            }

    and in the 

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                navigate a1 = e.Parameter as navigate;
                background.Source = a1.image1;
                myVar = a1.str1;

    }

    so that i can use it in button!

    Saturday, January 4, 2014 11:40 AM