Wpf 以数字开头的XAML命名空间
我已继承了Wpf 以数字开头的XAML命名空间,wpf,vb.net,xaml,namespaces,Wpf,Vb.net,Xaml,Namespaces,我已继承了按钮,并试图将其添加到我的主窗口中 它不会显示在工具箱中。我试过几次重建 我已经尝试添加xmlns:dc=“clr名称空间:123个字母和xmlns:dc=“clr名称空间:123个字母;assembly=123个字母到myMain窗口 我的主窗口是: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmln
按钮
,并试图将其添加到我的主窗口中
它不会显示在工具箱中。我试过几次重建
我已经尝试添加xmlns:dc=“clr名称空间:123个字母
和xmlns:dc=“clr名称空间:123个字母;assembly=123个字母
到myMain窗口
我的主窗口是:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="MainWin"
Title="123 Letters">
</Window>
<Button x:Class="WeatherStationButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</Button>
及
这是非常简单的东西。我相信这是因为XAML不允许在名称空间的第一部分使用数字,但我在任何地方都找不到任何有关该名称空间的引用,所以我想问一下我是否做错了什么,或者这是XAML的“功能”之一?刚刚意识到我可以添加我的答案
如果项目名称为123Letters
,则在XAML中引用第一个数字时,需要在其前面添加下划线,如\u 123Letters
然后,您的clr名称空间声明将是:
xmlns:dc="clr-namespace:_123Letters"
您可以将继承的按钮添加到主窗口,如下所示:
<dc:WeatherStationButton x:Name="btnWS" />
我是对的。XAML使用以数字开头的名称空间实现秘密魔法。必须在第一个数字前添加下划线,如:\u 123Letters
。除了我的尝试和错误,我没有其他的参考资料。
<dc:WeatherStationButton x:Name="btnWS" />