How to access MainPage.xaml controls from another page

i have an image element in the MainPage.xaml and a flyout in SettingsContract1.xaml, when the flyout item is clicked the filepicker is
opened and i want to set them image source of the image in the Mainpage with the file picked from the filepicker. How can i access the image from SettingsContract1.xaml
image in MainPage.xaml
<Image x:Name="img" HorizontalAlignment="Left" Height="332" VerticalAlignment="Top" Width="778" Margin="349,406,0,0"/>
menuflyout sub in SettingsContract1.xaml.vb
Private Sub chooseFile_Click(sender As Object, e As RoutedEventArgs) Handles chooseFile.Click
Dim filePicker As FileOpenPicker
filePicker = New FileOpenPicker()
filePicker.ViewMode = PickerViewMode.Thumbnail
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary
filePicker.FileTypeFilter.Add(".png")
Dim file As StorageFile = Await filePicker.PickSingleFileAsync()
Using filestream As Streams.IRandomAccessStream = Await file.OpenAsync(FileAccessMode.Read)
Dim bitmapImage As Windows.UI.Xaml.Media.Imaging.BitmapImage = New BitmapImage
bitmapImage.SetSource(filestream)
img.Source = bitmapImage 'gives an error
End Using
End Sub

Found the answer from stackoverflow
Private Async Sub chooseFile_Click(sender As Object, e As RoutedEventArgs) Handles chooseFile.Click
Dim mapImage As Frame = Window.Current.Content
Dim mainPage As MainPage = mapImage.Content
Dim filePicker As FileOpenPicker
filePicker = New FileOpenPicker()
filePicker.ViewMode = PickerViewMode.Thumbnail
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary
filePicker.FileTypeFilter.Add(".png")
Dim file As StorageFile = Await filePicker.PickSingleFileAsync()
Using filestream As Streams.IRandomAccessStream = Await file.OpenAsync(FileAccessMode.Read)
Dim bitmapImage As Windows.UI.Xaml.Media.Imaging.BitmapImage = New BitmapImage
bitmapImage.SetSource(filestream)
mainPage.img.Source = bitmapImage
End Using
End Sub

Similar Messages

  • How to access the component id from another mxml?

    I tried to set the data to a DataGrid in another mxml, but the complier said there's a problem, like this:
    the components/FileDataGrid.mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx" >
        <mx:DataGrid x="150" y="50" id="dgFile">       <mx:columns>
             <mx:DataGridColumn headerText="COL"/>
           </mx:columns>
        </mx:DataGrid>
    </s:Group>
    the main mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
              xmlns:custom="components.*" layout="absolute">
         <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
         </fx:Declarations>
         <fx:Script>
              <![CDATA[
                   private function loadDG():void
                        var arrFile:Array= new Array("abc","123");
                        dgFile.dataProvider = arrFile;
                        trace( "The data has successfully loaded" );
              ]]>
         </fx:Script>
         <s:Button  x="300" y="50" label="Load"  click="loadDG()" />
         <custom:FileDataGrid/>
    </mx:Application>
    The compiling error is :
    Multiple markers at this line:
    -1120: Access of undefined property dgFile.
    -arrFile
    Anybody can tell me, how to achieve it?
    Thanks a lot!

    Hi, You cant access it like this. To access, first give some id to the custom component you have added.
    i.e
    <custom:FileDataGrid id="custFDG"/>
    Then you can acces it from script,
    custFDG.dgFile.dataProvider = arrFile;
    Hope this shud work fine.
    Thanks.
    Abhinav

  • How to access component's control from main .mxml file?

    I have a main .mxml while in which i imported custom
    "popUpWindow" component using "import components.popUpWindow"
    statement. In main .mxml file I display later on that component as
    popUp window using popUp manager class:
    var popUpWin:IFlexDisplayObject;
    popUpWin = PopUpManager.createPopUp(this, popUpWindow, true);
    Once component is displayed, how can i access using
    actionscript component's TextInput control (specifically its .text
    property) from my main .mxml file?
    thanks

    msabljic , sounds like you ran into the same problem as me,
    perhaps... I posted a question similar to yours around the same
    time. Take a look at the responses I got and maybe that will help
    answer your question.
    Here's a link to the post
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1285775&enterthread=y

  • How to access my website created from another computer and location?

    I am a beginner.  My nephew made an e-commerce site for me using dreamweaver on a Mac.  I purchased dreamweaver cs5 and have windows vista.  He sent me the FTP address, username and password.  I opened dreamweaver and am asking what to do to access and download the files?

    but it keeps saying that the local files should match exactly to the web which I obviously don't have.
    What's the exact message?
    The whole purpose of connecting is to download remote files to local so they mirror each other.
    It describes how to up load but not download.
    Download is the exact opposite of upload.
    Select Remote View, select all files, click Get.
    When I get to that point, that will download all the webfiles into my local folder rewriting everything there?
    Yes.
    But you don't have any files locally which will be overwirtten, do you? Just an empty folder waiting to be filled with files from the Remote server.

  • My ipod touch has a huge collection of music that I don't want to lose or replace but my computer has now crashed beyond recovery. How can I access my itunes account from another computer or transfer my playlists to another computer from my ipod?

    My ipod touch has a huge collection of music that I don't want to lose or replace but my computer has now crashed beyond recovery. How can I access my itunes account from another computer or transfer my playlists to another computer from my ipod?

    You can transfer iTunes purchases to your "new" computer by
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    You can transfer other stuff by:
    Best iPod to PC
    How to transfer or sync files from iPod to PC - Windows mac iPhone iPod software reviews - Software Wiki

  • How to access my macbook pro from a windows pc?

    how to access my macbook pro from a windows pc?

    Depending on what you mean by "access" the following may help:
    File sharing: How to connect with File Sharing on your Mac - Apple Support
    One way (and there are others) for remote control and remote access between Mac and Windows: http://www.teamviewer.com/en/index.aspx

  • If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?

    If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?  I imported music from a CD into my compter at work and when I got home and went to my iTunes account none of the songs were in my library.  I also noticed that on my Work computer there were a couple songs that I had to click on the little 'cloud' icon before I could listen to them (these were not songs I imported they were songs that were already in my library).  Not sure if this makes semse...help.

    jamie171 wrote:
    My question is since I have imported them into my iTunes library from one computer why can't I access them from my iTunes library from another computer that I have authorized to access whats in my library?  Is there no way to import songs only once into the library and then access them from all my authorized computers?
    Only if you have iTunes Match or of the computers are on the same local network.

  • Can I access my itunes lib from another comp on my wireless network at home

    How can I access my itunes library from another computer in my home. The computers are on a wireless network. The computer that we have used as our main computer and that has our library on it is running Windows XP. The laptop that I want to use to access the library is running VISTA. ANy ideas?

    You can sign into the iTunes Store on it, but your library won't be automatically put onto it.
    (100361)

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How to link from another page directly to a photo within a Spry gallery?

    I have created a page that has a photo gallery using Donald's tutorial to make a spry photo gallery. I have a need to link to a specific photo in that gallery from another page. I have seen the discussions on how to do this with tabbed panels etc.. but wondering how to do it in this context.

    Add default slide to the constructor and use a similar process to http://foundationphp.com/tutorials/spry_url_utils.php
    var ImageSlideShow = new Spry.Widget.ImageSlideShow("#ImageSlideShow", {
        defaultSlide: 2,
        widgetID: "ImageSlideShow",
        injectionType: "replace",
        autoPlay: true,
        displayInterval: 4000,
        transitionDuration: 2000,
        componentOrder: ["view", "controls"],
        plugIns: [ Spry.Widget.ImageSlideShow.PanAndZoomPlugin ]
    Gramps

  • How do I get iCloud mail from another computer?

    I would like to access my iCloud mail from a friend's computer. How do I do that?

    I apologize for making an incorrect assumption.  After searching now for about 30 minutes I cannot find one conclusive article from Apple that states in plain terms that you cannot access your iCloud email from another computer. I cannot find anything in the ASC when i do a search either. That really seems absurd to me, and probably another reason why I refuse most of the iCloud services myself.
    Anyway, that is of not help to you and I apologize for that. This is the most conclusive evidence that I can find that states that you can't read iCloud email on another computer unless that computer is set up with iCloud.
    http://support.apple.com/kb/PH2638?viewlocale=en_US
    I hope for your sake, that I am missing something and it is possible to access mail from another computer, otherwise it is really pointless to rely on iCloud email. I/we have to be missing something somewhere ... I hope.

  • How to access a web service from a XLet

    Hello,
    I am new in software development to ITV and I dint find too many usefull information teaching how to access a web service from a XLet running in a STB. Are there anybody who can give me some help, maybe sample or tutorial?
    Gratefull
    David

    hi,
    you can "borrow" the source code from [Yambo a free soft open source presentation engine (AKA XML microbrowser Xlet )|http://www.cineca.tv/labs/mhplab/index-en.html] both local and on a http remote connection.
    hope it helps..
    bye
    andrea

  • How do I copy and paste from one page or file to another page or file - on the same screen?

    How do I copy and paste from one page or file to another - on the same screen?

      Open both of your images in the Editor. Click on the image you want to copy and press Ctrtl+A (select all) followed by Ctrl+C (copy) then click the tab for your other image and press Ctrl+V (paste)
    Alternatively click on your background image then simply drag the second image from the photo/project bin and drop it into the main editor workspace on top of the background image. Use the move tool to position and the corner handles of the bounding box to scale.

  • How do i move an app from one page to another

    how do i move an app from one page to another? When I upgraded to the latest software on my 4s, the camera went to the last page rather than remaining on the home page

    What Rudegar says is true, but it's a lot easier to rearrange icons in iTunes:
    Connect your phone and open iTunes. 
    Click on the Apps tab. 
    You will see your home screen in the main window, with the other screens in a scrollable column on the right. Scroll down and click on the last page to put it in main window. 
    Now scroll the column so the home page is visible on the right.
    Click on the Camera and drag it onto the home page at the right. 
    Be careful not to accidentally insert it into another app, thereby creating a group.

  • HT1386 How do I unsync my phone from another person's account?

    How do I unsync my phone from another person's account? Another family member's phone was synced into the computer. As I tried to sync my phone it automatically synced into the account of the other phone. How do I sync my phone under my name so I can sync what is on my phone?

    Create another user profile on the computer so that you can log in as yourself and have your own copy of iTunes.

Maybe you are looking for

  • FLV cue point script

    Does anyone have a script that will make the movie go to and play another frame of the movie when a Flash video cue point is reached?

  • Oracle 8i Stored Java Procedure and OAS 4.0.8

    Hi, I'd like to call a Java Stored Procedure from the OAS, like an ordinary PL/SQL package. The Java Stored Procedure should generate HTML-code to display in the browser. My first try was, to use the SQL wrapper function and the PL/SQL cartridge of t

  • No. of Transactions Per Sec.

    Hi, Please let me know the various constraints relating to transaction rate that an Oracle Server on WINNT or Solaris can support. Basically I would like to know its dependency on the Memory available, CPU speed, Table Size, no of sql statements in a

  • New personal domain problem

    So it seems that my personal domain isn't working as hoped. My CNAME alias was configured but it's acting funky. This points to the current changes I'm making in iWeb. http://web.mac.com/mingistech/ This points to the old page that was created in iWe

  • How to start more than one dbconsole...urgent pl help

    Sirs, We are running Oracle 10g/red hat linux. We have two databases running A and B. if i run "emctl start dbconsole" only am able to access db A. can we have two OEM running? thanks and regards, kt