Jon*_*ono 5 c# xaml visual-studio visual-studio-2017
我的问题与其他问题Enforce Global Namespace in XAML不同,因为我没有与封闭命名空间同名的类,但我想不出更合适的标题来区分这两者。
如果我的 XAML 对象的命名空间的任何部分也是另一个命名空间的根,则 Visual Studio 似乎更喜欢我的 XAML 对象的命名空间,这会表现为编译器错误。
这是一个示例,显示了我的命名空间的一部分WpfApp1.System.Views如何与 发生冲突global::System:
<Window x:Class="WpfApp1.System.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<!-- Amazing content goes here -->
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
错误窗格中显示了编译错误,并在以下部分obj/System/Views/MainWindow.g.i.cs下显示了一条波浪状的红色下划线:SystemSystem.Windows.Window
namespace WpfApp1.System.Views {
public partial class MainWindow : System.Windows.Window {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
显然,我的玩具示例只会阻止我在层次结构中的任何位置拥有System命名空间,但如果我在 XAML 中使用这些第三方组件之一,它也会阻止我拥有任何第三方名称(例如)。DevExpress
global::在不重命名我自己的命名空间(或引用的组件的命名空间)的情况下,我是否可以要求 Visual Studio在其生成的 XAML 代码中使用命名空间?
| 归档时间: |
|
| 查看次数: |
204 次 |
| 最近记录: |