Skip to main content

Microsoft Silverlight

Answered Question Bulding Custom Control... PLEASE HELP!RSS Feed

(0)

cyberwin
cyberwin

Member

Member

80 points

54 Posts

Bulding Custom Control... PLEASE HELP!

I have wasted 2 days trying to deal with this. I have no idea what is happening or where to start...

It could not be simpler. 

I am building a control that is actually a composite of several controls with some events handlers that govern their behavior... Anyway, nothing was working, so I went simple to try to work it up.

My generic.xaml is pretty simple... it has a canvas with a button in it. That is alll.

It compiles, just fine. But when I set the control on a xaml in my application, I get the ol AG_E_UNKNOWN_ERROR [Line: 64 Position: 24]

This only adds confusion because there is no file in my entire test application that has 64 lines! HAHAHA

Anyway. I did the normal stuff like changind the generic.xaml's properties (Build Action = Resource, Custom Tool = {blank}), etc...

Is there anything else I could look for or do?

generic.xaml
---

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WPControls">
    <Style TargetType="local:QuickFilter">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:QuickFilter">
                    <Canvas x:Name="RootElement" Background="Transparent" Height="65">
                        <Button Content="BITE ME!"/>
                        <ContentPresenter x:Name="ContentPresenter"/>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

QuickFilter.cs
---

namespace WPControls
{
    public class QuickFilter : UserControl
    {
        public QuickFilter()
        {
            DefaultStyleKey = GetType();
        }
    }
}
 

ANY advice would be appreciated.

Andrew S. Erwin
Software Developer


WadeFlextronics
WadeFlex...

Member

Member

377 points

82 Posts

Re: Bulding Custom Control... PLEASE HELP!

Try moving the Style into the App.xaml and see if that works.  There are several older posts that report this as a bug / issue.

Also, do you have the generic.xaml in the themes/ folder of you application?  This is a change between Beta 2 and RTW.

(Please mark as Answered if this helps!) Cool

Thanks,
Wade

cyberwin
cyberwin

Member

Member

80 points

54 Posts

Answered Question

Re: Bulding Custom Control... PLEASE HELP!

 There is, apperantly a bug in Silverlight Tools for VS2008 or something.

When I rebooted, this worked properly... Once this problem started, it happened with every custome control I had... Giving the same "unknown" error on line 64... (line 64 of what?)

Anyway... I never figured out the problem, but once I rebooted, it stopped...

 

Andrew S. Erwin
Software Developer


sysrpl
sysrpl

Member

Member

34 points

42 Posts

Re: Bulding Custom Control... PLEASE HELP!

 I am still a silverlight newb, but I believe you cannot attach a template to UserControl. Try making your base class a Panel instead.

cyberwin
cyberwin

Member

Member

80 points

54 Posts

Re: Bulding Custom Control... PLEASE HELP!

 No, I got it working.

 Not just my simple example, but my full compound control...

The issue wasn't with my control, but with visual studio...

Andrew S. Erwin
Software Developer


  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities