How to pass data from callback function to MainPage(another class) in Windows Phone 8

Proglamour

There are two class MainPage and Callback. I used C++ library, so I get byte array via CLI. When I get data callback class, I want pass the data callback class to MainPage class(It's UI thread). Finally, I want to draw Image after getting byte array.


<Image x:Name="ImageScreen" x:FieldModifier="public" Height="357" Width="456" Margin="0,33,0,201"/>

== MainPage.xaml.cs ==

public class Callback : ComponentCallback
{
    static byte[] byteArray;        
    ...
    // I get data via this function. When I get the data,
    // I want to pass the data to updateImage function in MainPage class.
    public void onFrameLoaded(int camera, String title, UInt32 bufferSize)
    {
        System.Collections.Generic.List<byte> buffer = MainPage._watcher.getBuffer().ToList();

        byteArray = buffer.ToArray();

        // I want pass byteArray to updateImage.
    }
}    

public partial class MainPage : PhoneApplicationPage
{
    public static Component _watcher;
    public static Callback _watcherCallback;

    public MainPage()
    {
        InitializeComponent();

        CoreComponent _core = new CoreComponent();
        int fenport = _core.fenServerPort();
        _core.setFenServer("", );
        fenport = _core.fenServerPort();

        _watcher = new Component();
        _watcherCallback = new Callback();
        _watcher.setCallback(_watcherCallback);
        _watcher.connect(0, "", 0, "", "");            
    }        

    public void updateImage(byte[] byteArray)
    {
        BitmapImage bi = new BitmapImage();
        MemoryStream stream = new MemoryStream(byteArray);
        bi.SetSource(stream);

        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            //Update the UI controls here
            ImageScreen.Source = bi;
        });
    }
}
Filip Skakun
var frame = Window.Current as Frame;

if (frame == null)
{
    return; //?
}

var mainPage = frame.Content as MainPage;

if (mainPage == null)
{
    return; //?
}

mainPage.updateImage(byteArray);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to pass multiple data between pages in windows phone

From Dev

how set style staticresource from data binding in Windows Phone 8

From Dev

How to do function based on ListPickerItem Selection in windows phone 8

From Dev

Pass a static function of an abstract class as a callback function

From Dev

Transferring data from one page to another windows 8 phone app

From Dev

How to auto update the content after fixed intervals in windows phone 8 page that retrieve data from Json

From Dev

How to pass data between Different Pages in Windows Phone 8.1

From Dev

How to pass in a variable to a .then() callback function from an outer scope?

From Dev

How can I call a class variable from a callback function?

From Dev

How to properly pass a callback-function from swift to c++?

From Dev

how to pass call value from callback function in tkinter

From Dev

How to force Windows Phone 8 to re-load data from server

From Dev

How to parse the Json data in windows phone 8

From Dev

how to create call function in windows phone 8 app?

From Dev

Pass cookie to WebBrowser in Windows Phone 8

From Dev

How to Parse Json data with Images in Windows Phone 8 from a URL? Dynamic data

From Dev

How to send windows phone 8 application data to server

From Dev

Windows Phone 8: passing data from PHP page to windows phone 8 app

From Dev

How to do function based on ListPickerItem Selection in windows phone 8

From Dev

Pass a static function of an abstract class as a callback function

From Dev

How to use data binding for radio buttons in windows phone 8

From Dev

How to pass $(this) to the callback function

From Dev

Best way to pass a class into a callback function

From Dev

how to pass variable from callback function to function call?

From Dev

How to connect windows phone 8 to database and apply azure sync data to it?

From Dev

Pass data from JSONP callback function to Angular controller

From Dev

How to pass data from class using a list

From Dev

How to callback a function in tableView's Class from tableViewCell's Class

From Dev

Node.js: Pass data from a callback to the calling function

Related Related

  1. 1

    How to pass multiple data between pages in windows phone

  2. 2

    how set style staticresource from data binding in Windows Phone 8

  3. 3

    How to do function based on ListPickerItem Selection in windows phone 8

  4. 4

    Pass a static function of an abstract class as a callback function

  5. 5

    Transferring data from one page to another windows 8 phone app

  6. 6

    How to auto update the content after fixed intervals in windows phone 8 page that retrieve data from Json

  7. 7

    How to pass data between Different Pages in Windows Phone 8.1

  8. 8

    How to pass in a variable to a .then() callback function from an outer scope?

  9. 9

    How can I call a class variable from a callback function?

  10. 10

    How to properly pass a callback-function from swift to c++?

  11. 11

    how to pass call value from callback function in tkinter

  12. 12

    How to force Windows Phone 8 to re-load data from server

  13. 13

    How to parse the Json data in windows phone 8

  14. 14

    how to create call function in windows phone 8 app?

  15. 15

    Pass cookie to WebBrowser in Windows Phone 8

  16. 16

    How to Parse Json data with Images in Windows Phone 8 from a URL? Dynamic data

  17. 17

    How to send windows phone 8 application data to server

  18. 18

    Windows Phone 8: passing data from PHP page to windows phone 8 app

  19. 19

    How to do function based on ListPickerItem Selection in windows phone 8

  20. 20

    Pass a static function of an abstract class as a callback function

  21. 21

    How to use data binding for radio buttons in windows phone 8

  22. 22

    How to pass $(this) to the callback function

  23. 23

    Best way to pass a class into a callback function

  24. 24

    how to pass variable from callback function to function call?

  25. 25

    How to connect windows phone 8 to database and apply azure sync data to it?

  26. 26

    Pass data from JSONP callback function to Angular controller

  27. 27

    How to pass data from class using a list

  28. 28

    How to callback a function in tableView's Class from tableViewCell's Class

  29. 29

    Node.js: Pass data from a callback to the calling function

HotTag

Archive