How to resolve namespace conflict in generated files for Silverlight
UserControl?
I am currently working on some kind of toolkit libraries for a large set
of Silverlight applications. These libraries provide components ready for
use with components of a 3rd party vendor in a dedicated assembly.
Lets say the root namespace of the library in question is named
MyCompany.MyToolkit.Vendor. Now I build a user control making use of
components of said vendor. Take the following file (let's say it's named
"MyControl.xaml") for example:
<UserControl xmlns:vendor="http://schemas.vendor.com/2008/xaml/presentation">
<vendor:SomeControl />
</UserControl>
VisualStudio then generates a .cs-file for MyControl.xaml named
MyControl.g.xaml. And there is an internal field representing the control
added in the XAML-code:
namespace MyCompany.MyToolkit.Vendor
{
public partial class MyControl : System.Windows.Controls.UserControl
{
internal System.Windows.Controls.UserControl root;
internal Vendor.Windows.Controls.SomeControl someControl;
// ...
}
}
And this results in a namespace conflict, because there is no such thing
as a Windows.Controls-namespace in my
MyCompany.MyToolkit.Vendor-namespace.
Using the global::-prefix would solve the issue:
internal global::Vendor.Windows.Controls.SomeControl someControl;
Unfortunately there seems to be no way to force VisualStudio to use this
prefix. Is there any way achieve this? Or do you know of any other way to
resolve this issue apart from renaming my library?
No comments:
Post a Comment