views:

38

answers:

2

Hi guys,

I created this class where I wanted to override this specific event for the content control.

public class MyContentControl : ContentControl
{
    protected override void OnKeyUp(KeyEventArgs e)
    {
        //do something 
        //..........
        e.Handled = true;
    }
}

However when I am using this control in my XAML everything compiles and works fine, but I am getting a runtime exception and I am not sure exactly why? Could someone point me in the right directions....

The exception I get is

XamlParseException

UPDATED (Shows where abouts of the exceptions)

In the XAML I have:

xmlns:ctrls="clr-namespace:SilverlightProject.CustomControls"

and I use it like:

<ctrls:MyContentControl Grid.Column="0" x:Name="_contentControl" VerticalAlignment="Center" HorizontalAlignment="Center" />
A: 

Content controls require a default template to be created somewhere (e.g. in generic.xaml). They do not have a matching XAML file like user controls.

If you can provide more information, I can show you how to create an appropriate template.

Enough already
What kind of information could I provide?
VoodooChild
The problem you are trying to solve/purpose of the control. The more you provide with code/XAML the easier it is to understand and provide a solution/example.
Enough already
If you do not wish to publish too much here you can always contact us though our website. Happy to provide examples/advice (away 'til Sunday though).
Enough already
A: 

There are many reasons for this.
To start with. Give the fully qualified namespace.

Instead of

xmlns:ctrls="clr-namespace:SilverlightProject.CustomControls"

Use

xmlns:ctrls="clr-namespace:SilverlightProject.CustomControls;assembly=YourAssebmlyName"

If that, doesn't help. You directly attach your control with the application. Then, enable Debug -> Exceptions. Check Thrown option for the CLR execetion checkbox. You have fair amount of possibility to get to know the cause.

Avatar
BY adding the `assembly` I am getting an exception "Assembly....has been tampered with!"
VoodooChild
Do you use key file for signing the assembly?
Avatar
No I don't think so, I am not even sure what that is...
VoodooChild
Sorry, no clue :( Let me observe this post as well.
Avatar