Hyperlink Click

Sep 15, 2010 at 2:55 PM
I just switched from Caliburn 1.1 to Micro because all I basically need, is the Action stuff.
I replaced the assembly reference and basically it seems to work just fine, except with hyperlinks:

  <Hyperlink cal:Message.Attach="[Event Click] = [Action StartCfgModule('ReceiptPrinterConfiguration')]">
Receipt Printer

While this worked with Caliburn, Micro throws an exception (see below).

There is a default convention for the Hyperlink class, so I guess it's probably intended to be working. But a HyperLink is a FrameworkContentElemnt, not a FrameworkElement. And as far as I can see,
there's no common base class or interface that could make ActionMessage easily happy. And as there's no HyperlinkButton in WPF, I probably have to stick with a custom button style to work around this issue.


System.InvalidOperationException was unhandled by user code
  Message=Cannot attach type "ActionMessage" to type "Hyperlink". Instances of type "ActionMessage" can only be attached to objects of type "FrameworkElement".
       bei System.Windows.Interactivity.TriggerAction.Attach(DependencyObject dependencyObject)
       bei System.Windows.Interactivity.TriggerActionCollection.OnAttached()
       bei System.Windows.Interactivity.AttachableCollection`1.Attach(DependencyObject dependencyObject)
       bei System.Windows.Interactivity.TriggerBase.Attach(DependencyObject dependencyObject)
       bei System.Windows.Interactivity.TriggerCollection.ItemAdded(TriggerBase item)
       bei System.Windows.Interactivity.AttachableCollection`1.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       bei System.Windows.FreezableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei System.Windows.FreezableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Int32 oldIndex, T oldValue, Int32 newIndex, T newValue)
       bei System.Windows.FreezableCollection`1.AddHelper(T value)
       bei System.Windows.FreezableCollection`1.Add(T value)
       bei Caliburn.Micro.ExtensionMethods.Apply[T](IEnumerable`1 enumerable, Action`1 action) in C:\Users\tobias\sandbox\caliburnmicro\src\Caliburn.Micro.Silverlight\ExtensionMethods.cs:Zeile 39.
       bei Caliburn.Micro.Message.OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in C:\Users\tobias\sandbox\caliburnmicro\src\Caliburn.Micro.Silverlight\Message.cs:Zeile 60.
       bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       bei System.Windows.FrameworkContentElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       bei System.Windows.Documents.TextElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       bei System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       bei System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       bei System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value)
       bei MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
       bei MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)

Sep 15, 2010 at 3:10 PM

Yeah. Unfortunately, WPF has FCE which the other two platforms do not...and there really isn't a common interface between FCE and FE, so there is no way to write framework code that generically works against both. Trying to work around this issue was going to cause a lot of complexity and increase the codebase size significantly, which is exactly what I didn't want for Micro. As a result, I decided to sacrifice FCE. Hyperlink is the main control that gets hit by this in WPF...that and one control from DevExpress. You could create a TextBlock with some styling and just use it's left mouse up event as a reasonable workaround.

Sep 15, 2010 at 3:29 PM

Will this happen to Caliburn as well, if it starts to use System.Windows.Interactivity too?

BTW: Can System.Windows.Interactivity.dll be redistributed standalone without the Expression Blend SDK?

Sep 15, 2010 at 3:49 PM

No, the implementation for Caliburn will be a bit more complicated in order to support FCE. However, I'm still not sure I'm going to do that. It's a lot of work...Not sure about the distribution of System.Windows.Interactivity.dll I would imagine you can distribute it with your app without the other assemblies. Is that what you mean?

Sep 15, 2010 at 3:55 PM

No I just mean the legal point of view for the redistribution of this dll outside of the SDK.