This project is read-only.

Inheritance and derived class from MediaPlayer

Topics: Windows 8 Xaml
Jan 21, 2013 at 1:20 PM

I open a new thread concerning the use of a MediaPlayer's derived class in Windows 8 App.My issue : When I used my MediaController inheriting MediaPlayer class, and I add it to the layoutTree like another normal inheriting control class (Button, etc..) this call an unknow exception. Here my simple following code.

From my class : 

public class MediaController: MediaPlayer
        public MediaController() : base()  { }


From my application page :

public sealed partial class MainPage : Page
        public MainPage()

            //MediaPlayer myMedia = new MediaPlayer();
            MediaController media = new Ad2PlayController();
            this.LayoutRoot.Children.Add(media); //LayoutRoot is my principal grid

My question : "Is that possible to create a simple inheriting class of MediaPlayer which can be used in the user interface in this way, and how to do it ?"

Thanks in advance for your reply ! 

Best Regards,


Jan 21, 2013 at 10:38 PM

Hello Max, there are some interesting things unique to Win8 that happen at build time where the tools scan your xaml and look for all types ahead of time in order to generate the appropriate XamlTypeInfo classes required to use the control (at least that's how I understand it).

The easiest way to get around this is to create a fake version of your subclassed control in xaml ahead of time (either in app.xaml or in your page) and just make sure it's invisible. For example:

<local:MediaController x:Name="junk" Visibility="Collapsed"/>

You might also be able to create your own XamlTypeInfo class to avoid this step but I haven't tried this yet.


Jan 22, 2013 at 8:59 AM

Hello Tim,

Thank you for your advise, that's great ! That was exactly what i expected.
I wish you to have a nice day !

Best Regards,