Gibbsnich
Gibbsnich

Reputation: 33

Image control in Win 8 Phone?

I inherited some classes (c#) from standard controls like Button and CheckBox in my windows phone app - no problem!

But i cannot inherit from Image and don't know why.

The code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace SPSClient.Objekte {
    public class SPSImage : Image {
        public int status { get; set; }
        public SPSImage() {
            this.status = 0;
        }
    }

is ok for the compiler, but it doesn't work, because SPSImage has no methods or properties at all.
Unlike the others classes, where the inherited object is colored correctly in the editor, "Image" stays in black, as it was not recognized as an existing object.

Since i can use Image in my XAML files, it is definitely available in win phone, but how can i access it in C#?

Could it be, that the class Image is sealed?

Upvotes: 0

Views: 117

Answers (1)

Igor Ralic
Igor Ralic

Reputation: 15006

Image control/class is sealed, therefore you can't inherit from it.

Possible "workaround" (depending on what you need, really) is to have your own class hold Image inside as a property with other properties, exposing them for whatever you may need... Or maybe just hold a bitmap source in your class, not the control itself...?

Upvotes: 2

Related Questions