Is there anyway to specify the assembly along with the namespace in C#?
For instance, if you reference both PresentationFramework.Aero
and PresentationFramework.Luna
in a project you might notice that both of them share the same controls in the same namespace but with different implementation.
Take ButtonChrome
for example. It exists in both assemblies under the namespace Microsoft.Windows.Themes
.
In XAML you include the assembly along with the namespace so here it's no problem
xmlns:aeroTheme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:lunaTheme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
<aeroTheme:ButtonChrome ../>
<lunaTheme:ButtonChrome ../>
But in C# code behind I can't find anyway to create an instance of ButtonChrome
in PresentationFramework.Aero
.
The following code gives me error CS0433 when compiling
using Microsoft.Windows.Themes;
// ...
ButtonChrome buttonChrome = new ButtonChrome();
error CS0433: The type 'Microsoft.Windows.Themes.ButtonChrome' exists in both
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\PresentationFramework.Aero.dll'
and
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\PresentationFramework.Luna.dll'
Which is very understandable, the compiler has no way of knowing which ButtonChrome
to choose because I haven't told it. Can I do that somehow?