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 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> |
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