将用户控件添加到 wpf 窗口 [英] Add a user control to a wpf window

查看:40
本文介绍了将用户控件添加到 wpf 窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个用户控件,但是当我将它添加到窗口中的 XAML 时,Intellisense 没有选择它,我不知道如何将它添加到窗口中.

I have a user control that I've created, however when I go to add it to the XAML in the window, Intellisense doesn't pick it up, and I can't figure out how to add it to the window.

推荐答案

需要在 window 标签内添加引用.类似的东西:

You need to add a reference inside the window tag. Something like:

xmlns:controls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"

(当你添加 xmlns:controls=" intellisense 时,应该启动以让这更容易一些)

(When you add xmlns:controls=" intellisense should kick in to make this bit easier)

然后你可以添加控件:

<controls:CustomControlClassName ..... />

这篇关于将用户控件添加到 wpf 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆