예제 #1
0
        //Pass data in an application-level variable
        // defined in App.xaml.cs.
        private void PassDataInApplicationVariable(int button)
        {
            method = PassingDataMethod.ApplicationVariable;

            //Change the textblock source depending on which convert button is pressed
            if (button == 1)
            {
                string unitIndexString = truthBlock.Text;
                int    unitIndex1      = Convert.ToInt32(unitIndexString);

                string unitIndexString2 = truthBlock2.Text;
                int    unitIndex2       = Convert.ToInt32(unitIndexString2);

                (Application.Current as App).unitIndex1 = unitIndex1;
                (Application.Current as App).unitIndex2 = unitIndex2;
            }
            else if (button == 2)
            {
                string unitIndexString = truthBlock3.Text;
                int    unitIndex1      = Convert.ToInt32(unitIndexString);

                string unitIndexString2 = truthBlock4.Text;
                int    unitIndex2       = Convert.ToInt32(unitIndexString2);

                (Application.Current as App).unitIndex1 = unitIndex1;
                (Application.Current as App).unitIndex2 = unitIndex2;
            }


            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
예제 #2
0
// Handle selection changed on length Top LongListSelector



        private void lengthLeftList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            if (lengthLeftList.SelectedItem == null)
            {
                return;
            }

            // Get the index of the selected item in the LongListSelector
            int selectedIndex = App.ViewModel.length.Items.IndexOf(lengthLeftList.SelectedItem as ConversionData);

            string indexstring = selectedIndex.ToString();

            truthBlock.Text = indexstring; // use this to pass the value of selectedIndex to PassDataInApplicationVariable()



            method = PassingDataMethod.ApplicationVariable;

            string unitIndexString = truthBlock.Text;
            int    unitIndex1      = Convert.ToInt32(unitIndexString);

            (Application.Current as App).unitIndex1 = unitIndex1;



            // Navigate to the next page
            NavigationService.Navigate(new Uri("/LengthPage2.xaml", UriKind.Relative));


            // Reset selected item to null (no selection)
            lengthLeftList.SelectedItem = null;
        }
예제 #3
0
        private void volumeList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            if (volumeList.SelectedItem == null)
            {
                return;
            }

            //int selectedIndex = App.ViewModel.Items.IndexOf(weightTopList.SelectedItem as ConversionModel);
            int selectedIndex = App.ViewModel.volume.Items.IndexOf(volumeList.SelectedItem as ConversionData);


            string indexstring = selectedIndex.ToString();

            truthBlock3.Text = indexstring; // use this to pass the value of selectedIndex to PassDataInApplicationVariable()

            method = PassingDataMethod.ApplicationVariable;

            string unitIndexString = truthBlock3.Text;
            int    unitIndex1      = Convert.ToInt32(unitIndexString);

            (Application.Current as App).unitIndex1 = unitIndex1;

            // Navigate to the next page
            NavigationService.Navigate(new Uri("/VolumePage2.xaml", UriKind.Relative));

            // Reset selected item to null (no selection)
            volumeList.SelectedItem = null;
        }