Skip to main content

Microsoft Silverlight

Answered Question AG_E_PARSER_BAD_TYPE when extending controlRSS Feed

(0)

toppless
toppless

Member

Member

1 points

12 Posts

AG_E_PARSER_BAD_TYPE when extending control

 Hi,

i'm trying to extend a button to enrich it with my own functionality. But running my test application produces AG_E_PARSER_BAD_TYPE exception.
Code snippets:

MainControl.xaml.cs

using System.Windows.Controls;

namespace TestApp
{
    public partial class MainControl : UserControl
    {
        public MainControl()
        {
            // Required to initialize variables
            InitializeComponent();

        }

    }
}

 MainControl.xaml

<UserControl
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:usr="clr-namespace:TestApp;assembly=TestApp"
x:Class="TestApp.MainControl">
<Grid x:Name="LayoutRoot" Background="White">
<usr:MyButton>
</usr:MyButton>
</Grid>
</
UserControl>

MyButton.cs

using System.Windows.Controls;
namespace TestApp
{
    partial class MyButton : Button
    {
        public MyButton()
            : base()
        {
        }
    }
}
Can somebody tell me what is going wrong?
 
THX

Roet
Roet

Member

Member

211 points

65 Posts

Answered Question

Re: AG_E_PARSER_BAD_TYPE when extending control

Why did you make the MyButton class partial, and not public?

If this post helped you, please mark it as answer! It helps other people too.

varshavmane
varshavmane

Contributor

Contributor

6733 points

1,580 Posts

Re: AG_E_PARSER_BAD_TYPE when extending control

Check this post :

http://silverlight.net/forums/t/65077.aspx

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

Roet
Roet

Member

Member

211 points

65 Posts

Re: AG_E_PARSER_BAD_TYPE when extending control

By the way, did you have quotes around the xmlns?

 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

should be:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

If this post helped you, please mark it as answer! It helps other people too.

toppless
toppless

Member

Member

1 points

12 Posts

Re: Re: AG_E_PARSER_BAD_TYPE when extending control

Thanks "internal" was a copy & paste mistake.

Originally i was trying to take a Silverlight Button source code and try to rename the types. But somehow i stuck on the ResourceDictionary. Could you give me advice, which part of the generic.xml should i take an modify in order to get it workin as my own "MyButton"?

And yes, i have quotes on xmlns. Editor just kicked them out.

toppless
toppless

Member

Member

1 points

12 Posts

Re: Re: Re: AG_E_PARSER_BAD_TYPE when extending control

Got it working. Had a typo in the ControlTemplate/TargetType definition.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities