I have two projects, Project A is a WPF Application and Project B is a WPF Control Library.
Project A References default WPF stuff. But not System.Windows.Controls.Ribbon
.
Project B defines a class MainWindow
which inherits from RibbonWindow
, located in the System.Windows.Controls.Ribbon
Assembly.
Inside the App.xaml.cs im going to set the Current.MainWindow
instance to a MainWindow
of Project B
Current.MainWindow = factory.CreateMainWindow(); // Returns of type `MainWindow`
This causes the following Build-Errors:
CS0012: The type 'RibbonWindow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
CS0029: Cannot implicitly convert type 'MyNamespace.MainWindow' to 'System.Windows.Window'
It can be solved referencing
System.Windows.Controls.Ribbon
from Project A
As you can see, MainWindow
is a RibbonWindow
which is a Window
.
Current.MainWindow
requires a Window
to be set. The MainWindow
returned by factory.CreateMainWindow()
is to be converted implicitly to Window
.