Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Bulding Custom Control... PLEASE HELP!
4 replies. Latest Post by cyberwin on October 29, 2008.
(0)
cyberwin
Member
80 points
54 Posts
10-29-2008 12:33 PM |
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.
WadeFlex...
377 points
82 Posts
10-29-2008 1:52 PM |
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.
10-29-2008 3:17 PM |
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...
sysrpl
34 points
42 Posts
10-29-2008 5:01 PM |
I am still a silverlight newb, but I believe you cannot attach a template to UserControl. Try making your base class a Panel instead.
10-29-2008 5:26 PM |
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...