我有一个我已经创建的用户控件,但是当我将它添加到窗口中的XAML时,Intellisense没有获得它,并且我不知道如何将它添加到窗口中。
发布于 2009-07-07 16:44:24
您需要在窗口标记内添加一个引用。类似于:
xmlns:controls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"
(当你添加xmlns:controls=时,智能感知应该会让这变得更容易一些)
然后,您可以使用以下命令添加控件:
<controls:CustomControlClassName ..... />
发布于 2009-07-07 16:45:13
您可能需要添加namespace
<Window x:Class="UserControlTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UserControlTest"
Title="User Control Test" Height="300" Width="300">
<local:UserControl1 />
</Window>
发布于 2009-07-07 16:45:59
确保您的控件所属的命名空间有命名空间定义(xmlns
)。
xmlns:myControls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"
<myControls:thecontrol/>
https://stackoverflow.com/questions/1093429
复制相似问题