Forum Xamarin.Mac

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Set Image property of other class's NSImageView

Hello everyone:

I am creating a view controller with NSOutlineView in it, and I create delegate of that to handle item selected, etc. But when I want to set the Image property of a NSImageView in the delegate class, a null exception of the NSImageView I called throw out. How could I deal with this problem?

Some codes here:

public class OutlineEventDelegate : NSOutlineViewDelegate
{
    //Delegate Implementation here

    public override bool ShouldSelectItem(NSOutlineView outlineView, NSObject item)
    {
        //Something else here
        try
        {
            NSImage image = new NSImage(new NSUrl(sURL));
            EventView eventView = new EventView();
            eventView.LoadEventImage(image);
        }
        catch(Exception ex)
        {
            //Something else here
        }
        return true;
    }
}

public partial class EventView : NSViewController
{
    //Something else here
    public EventView()
    {
    }

    public void LoadEventImage(NSImage event_image)
    {
        this.imageView.Image = event_image; //exception throw
    }
}
Sign In or Register to comment.