I made it! Mega refactoring using the specializing approach. It works perfectly. I don't know what was wrong on the first attempts.
I only have one problem, is with the custom button i have created. Addind the namespace to the default namespace makes the MenuButton an invalid type in styles, even with the prefix. However, it compiles and runnes. It only doesnt work on Blend. Its not
a big thing, but it messes my layout a little bit in Blend.
Do you know how to workaround this problem?
Thx,
Nuno
--
Imagining (and touching) the future
http://www.nunosantos.net/
http://www.myspace.com/sinosoidal
I have a more serious problem in Blend. When i open a SectionControl (my inherited class), it says i cant have content, so i cant use Blend at all.
can't use Blend at all? Why? you can still using it but yes, you will get nothing in designer.. Yes. it's bad. .. What I used to do is that i used Usercontrol (normal one) if I want to do some designing stuffs and animations.. then, change it back to inherited
once after that.
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
I've got another problem, very similar to the previous one.
I've got my own User Control with some XAML definition code and I want to inherit from this class:
ControlTwo does not have any XAML code, it just derives from ControlX. I guess, that it's not agains rules, but the XAML parser is thinking otherwise.
Small update: Page.xaml contains:
I am having the exactly same error. When I put on the page just the base class, it works fine. But if I put there the inherited one it throws unhandled exception (AG_E_PARSER_BAD_TYPE) in InitializeComponent() in base class!
sinosoidal
Member
664 Points
373 Posts
Re: Silverlight User Control Inheritance
Apr 15, 2008 05:04 PM | LINK
Hi,
I made it! Mega refactoring using the specializing approach. It works perfectly. I don't know what was wrong on the first attempts.
I only have one problem, is with the custom button i have created. Addind the namespace to the default namespace makes the MenuButton an invalid type in styles, even with the prefix. However, it compiles and runnes. It only doesnt work on Blend. Its not a big thing, but it messes my layout a little bit in Blend.
Do you know how to workaround this problem?
Thx,
Nuno
Imagining (and touching) the future
http://www.nunosantos.net/
http://www.myspace.com/sinosoidal
sinosoidal
Member
664 Points
373 Posts
Re: Silverlight User Control Inheritance
Apr 15, 2008 05:31 PM | LINK
Hi Michael,
I have a more serious problem in Blend. When i open a SectionControl (my inherited class), it says i cant have content, so i cant use Blend at all. :S
How can i work around this?
Thx,
Nuno
Imagining (and touching) the future
http://www.nunosantos.net/
http://www.myspace.com/sinosoidal
mchlSync
Star
14968 Points
2799 Posts
Re: Silverlight User Control Inheritance
Apr 15, 2008 05:32 PM | LINK
AFAIK, there is no wordaround for that.If we use User control inheritance in Silverlight, we will lost visual designer in Blend and VS.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
mchlSync
Star
14968 Points
2799 Posts
Re: Silverlight User Control Inheritance
Apr 15, 2008 05:48 PM | LINK
can't use Blend at all? Why? you can still using it but yes, you will get nothing in designer.. Yes. it's bad. .. What I used to do is that i used Usercontrol (normal one) if I want to do some designing stuffs and animations.. then, change it back to inherited once after that.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
sinosoidal
Member
664 Points
373 Posts
Re: Silverlight User Control Inheritance
Apr 15, 2008 06:23 PM | LINK
Is this a standard behaviour? Is that offical
What does Blend expect from the inherited class that UserControl has and the specialized not?
Can we manually insert something in the class that will make it work?
Oh god...
Nuno
Imagining (and touching) the future
http://www.nunosantos.net/
http://www.myspace.com/sinosoidal
Necroman
Member
20 Points
7 Posts
Re: Silverlight User Control Inheritance
Apr 22, 2008 04:11 PM | LINK
I've got another problem, very similar to the previous one.
I've got my own User Control with some XAML definition code and I want to inherit from this class:
<UserControl x:Class="Test1.ControlX"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" ShowGridLines="True">
<Ellipse Width="50" Height="30" Grid.Column="1" Grid.Row="1" />
</Grid>
</UserControl>
public partial class ControlX : UserControl
{
public ControlX()
{
InitializeComponent();
}
}
and then
public class ControlTwo : ControlX
{
public ControlTwo()
: base()
{
}
}
the program compiles, but when I try to instantiate ControlTwo class, it fails with error:
AG_E_PARSER_BAD_TYPE, on the line with InitializeComponent(); in ControlX.
So, where's the problem? Am I using bad syntax, or am I missing some workaround stuff? Thanks for help!
sinosoidal
Member
664 Points
373 Posts
Re: Silverlight User Control Inheritance
Apr 22, 2008 04:22 PM | LINK
Hi,
Usually i got that error when there is no definition in code for a event handler that is declared in xaml or when there is not such property in xaml.
Nuno
Imagining (and touching) the future
http://www.nunosantos.net/
http://www.myspace.com/sinosoidal
mchlSync
Star
14968 Points
2799 Posts
Re: Silverlight User Control Inheritance
Apr 22, 2008 04:22 PM | LINK
Can you show the XAML code for ControlTwo?
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
Necroman
Member
20 Points
7 Posts
Re: Silverlight User Control Inheritance
Apr 22, 2008 04:45 PM | LINK
ControlTwo does not have any XAML code, it just derives from ControlX. I guess, that it's not agains rules, but the XAML parser is thinking otherwise.
Small update: Page.xaml contains:
<UserControl x:Class="Test1.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:Test1"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" >
<i:ControlTwo Width="100" Height="100"/>
</Grid>
</UserControl>
Filipus
Member
25 Points
18 Posts
Re: Silverlight User Control Inheritance
Apr 23, 2008 04:46 AM | LINK
Hi all,
I am having the exactly same error. When I put on the page just the base class, it works fine. But if I put there the inherited one it throws unhandled exception (AG_E_PARSER_BAD_TYPE) in InitializeComponent() in base class!
the inherited class looks like this:
XAML
<BaseListItemControl x:Class="ItemsControls.TestItemListControl"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</BaseListItemControl>
CS:
namespace ItemsControls
{
public partial class TestItemListControl : BaseListItemControl
{
public TestItemListControl()
{
InitializeComponent();
}
}
}
-Filip