This is a migrated thread and some comments may be shown as answers.

Request for closer information about routed events

2 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 20 Apr 2009, 10:11 AM

Hi,

I hope you can give me some clarity about RoutedEvents (not about the thing at all - I know it from WPF) my question is about your Silverlight implementation.
I first tried it with the help - but there is no chapter about routed events - I can only find the class documentation.

I watched this session:
http://blogs.telerik.com/NikolayAtanasov/Posts/09-02-05/New_Training_Session_on_Silverlight_Routed_Events.aspx

And as I saw in the TOC there is a topic "set from XAML" I thought - wow - great.
But by watching the sample I saw the at the "from XAML" part there was only a demonstration that I can consume this event defined on the button in XAML - that has nothing to do with RoutedEvents - it's just a proof that the implemented property is accessible from XAML.

The code looks like this:

<StackPanel Name="ButtonPanel" Grid.Column="0" Background="LightGray" Orientation="Horizontal" HorizontalAlignment="Center" > 
    <MyControls:MyButton Name="btnYes" Content="Yes" Height="50" Width="50" Margin="2" PreviewPressed="MyButton_PreviewPressed"></MyControls:MyButton> 
    <MyControls:MyButton Name="btnNo" Content="No" Height="50" Width="50" Margin="2"></MyControls:MyButton> 
    <MyControls:MyButton Name="btnCancel" Content="Cancel" Height="50" Width="50" Margin="2"></MyControls:MyButton> 
</StackPanel> 
 
So as you can see - the "routed event" is assigned on the button - but in this case it isn't what I want to have from a routed event.
So I gave it a try (if it really works from XAML - in code behind it works I know) and changed the code like this:
<StackPanel MyControls:MyButton.PreviewPressed="myPressed" Name="ButtonPanel" Grid.Column="0" Background="LightGray" Orientation="Horizontal" HorizontalAlignment="Center" > 
    <MyControls:MyButton Name="btnYes" Content="Yes" Height="50" Width="50" Margin="2" PreviewPressed="MyButton_PreviewPressed"></MyControls:MyButton> 
    <MyControls:MyButton Name="btnNo" Content="No" Height="50" Width="50" Margin="2"></MyControls:MyButton> 
    <MyControls:MyButton Name="btnCancel" Content="Cancel" Height="50" Width="50" Margin="2"></MyControls:MyButton> 
</StackPanel> 
 
So thats what I would do in WPF - or in other words what I would do to assign routed events in XAML.
BUT - it does not compile. VS tells me that MyButton does not provide such an "appendable property".

So am I doing something wrong or does this simply mean that your RoutedEvent implementation does not support XAML?

Regards

Manfred

2 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 21 Apr 2009, 04:04 PM
Hi Manfred,

Unfortunately the Silverlight XAML parser does not allow us to add support for attaching event handlers in XAML and as far I can see, this is the biggest limitation of our routed events implementation.

Kind regards,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 21 Apr 2009, 04:07 PM
Tank you for this information.
It doesn't make me happy (not your fault I know) - but it prevents me from searching.

Regards

Manfred
Tags
General Discussions
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Valeri Hristov
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or