Right, so here the scenario:
I’ve created a class called “DiaryPage” that inherites from Canvas
I’ve created a usercontrol called “DiaryControl” that contains “DiaryPage” elements. The page’s height, width and so on are all databound like so :
Width="{Binding DataContext.Info.Booktype, ConverterParameter=CoverWidth, Converter={StaticResource BookTypeToDimentionsConverter}, FallbackValue=490, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=UserControl}}"
Now, It works perfectly on pc, running silverlight 5 BUT the same code running on a mac produces the following exception:
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Life.Views.Book.Framework.DiaryControl.InitializeComponent()
at Life.Views.Book.Framework.DiaryControl..ctor()Method not found: ‘Void System.Windows.FrameworkElement.add_DataContextChanged(System.Windows.DependencyPropertyChangedEventHandler)’.
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Life.Views.Book.Framework.DiaryControl.InitializeComponent()
at Life.Views.Book.Framework.DiaryControl..ctor()The invocation of the constructor on type ‘Life.Views.Book.Framework.DiaryPageControl’ that matches the specified binding constraints threw an exception.
The invocation of the constructor on type ‘Life.Views.Book.Framework.DiaryPageControl’ that matches the specified binding constraints threw an exception. [Line: 327 Position: 28]
[Line 327] corresponds to the Width binding specified above
Any ideas?
In my DiaryPage class i have a datacontextchanged listener attached like so:
DataContextChanged += new DependencyPropertyChangedEventHandler(DiaryPageControl_DataContextChanged);
void DiaryPageControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if(DataContext != null && DataContext.GetType()== typeof(Page))
LoadContent();
}
As I said, works a charm on windows (tested 5 pc’s), but throws exception on mac (well, the one that I’ve tried)
Silverlight should work exactly the same way on Mac and Windows PCs. This sounds like a bug. You might want to report it on the Microsoft Connect site. To solve your immediate issue you are just going to have to do a bit of exploratory work to find the part of the framework which is not working for you and avoid it!
One other point … make sure the Mac has the latest Silverlight version installed, you are using a relatively new framework feature there.